差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
it:server:security [2022-08-13 09:44] – [cloudflare] goldentianyait:server:security [2023-08-08 15:55] (当前版本) – [ACME 证书] goldentianya
行 45: 行 45:
   - 强制删除 <color #ff7f27>''%%rm -rf /etc/iptables && reboot%%''</color>   - 强制删除 <color #ff7f27>''%%rm -rf /etc/iptables && reboot%%''</color>
  
-====== SSL 证书 ====== 
-利用Cerbot(([[https://certbot.eff.org/lets-encrypt/ubuntufocal-nginx|SSL Certificates with Certbot]]))获取证书。按照官网的指令([[https://certbot.eff.org|官方文档]]) ([[https://www.cnblogs.com/redirect/p/10140248.html|中文文档]]), 
-<konsole> 
-$ sudo apt install snap 
-$ sudo snap install core; sudo snap refresh core 
-$ sudo snap install --classic certbot 
-$ sudo ln -s /snap/bin/certbot /usr/bin/certbot 
-$ sudo certbot --nginx # 应用此证书到Nginx服务器 
-</konsole> 
  
-最后为两个域名生成证书,将这两份证书重新复制到别的主机,应该也可以用。 +[[https://cloud.tencent.com/developer/article/1334624|常用命令]]
-<konsole> +
-Successfully received certificate. +
-Certificate is saved at: /etc/letsencrypt/live/wiki.goldentianya.de/fullchain.pem +
-Key is saved at:         /etc/letsencrypt/live/wiki.goldentianya.de/privkey.pem +
-This certificate expires on 2021-10-21. +
-These files will be updated when the certificate renews. +
-Certbot has set up a scheduled task to automatically renew this certificate in the background. +
-</konsole>+
  
-显示当前证书:<color #ff7f27>''%%certbot certificates%%''</color>\\ 
-证书的有效期为三个,需要用下面命令定期更新:<color #ff7f27>''%%sudo certbot renew --dry-run 
-%%''</color> \\ 
-或者添加定时任务 <color #ff7f27>''%%0 0 1 * * /usr/bin/certbot renew --quiet%%''</color> (每月1号更新一下)\\ 
-接着到Nginx的conf配置文件中更改证书目录就可以了。 
-如果需要迁移的第二台服务器,直接压缩certbot的文件夹就好了。 <color #ff7f27>''%%tar zpcvf backup.tar.gz /etc/letsencrypt/%%''</color> 
- 
- 
-为主域名和下面的子域名申请通配证书 
-(([[https://www.infoq.cn/article/2018/03/lets-encrypt-wildcard-https|Let's Encrypt 宣布支持通配符证书]]))  
-<code bash> 
-certbot certonly  -d *.simperator.com --manual --preferred-challenges dns 
-# -d 为那些主机申请证书,如果是通配符,输入 *simperator.com 
-# –preferred-challenges dns,使用 DNS 方式校验域名所有权 
-</code> 
-<color #c3c3c3>* 可以使用certonly或run命令来创建一个新证书,即使已经存在具有该域名的证书,也没有关系,那么certbot会更新该证书,否则会创建一个新证书,一句话存在就更新,不存在就创建</color> 
- 
-按照指示添加TXT记录,成功后存储在 <color #7092be>/etc/letsencrypt/archive/simperator.com</color> 
- 
-校验证书: 
-<code bash> 
-openssl x509 -in  /etc/letsencrypt/archive/simperator.com/cert1.pem -noout -text 
-</code> 
- 
-为域名更换证书 [[https://askubuntu.com/questions/1009896/how-to-change-letsencrypt-certbot-domain|change Domain]] 
- 
-更新邮件地址  
-<code | download> 
-certbot register --update-registration --email <email> 
-certbot update_account --email [email protected] 
-</code> 
- 
-打开 <color #7092be>/etc/letsencrypt/renewal</color> 文件夹下查看 *.conf 文件就能知道目前用的是哪个 ++ account | ab1af729afa2219047bb043c53f97fc9 ++ 。(当前我申请的两个证书都是同一个aacount) 
- 
-为每一个子域名配置证书,如 xx.simperator.com,有多少个子网站就重复多少次。Certbot会找到Nginx并正确的配置。 
-<code bash> 
-certbot --nginx -d fun.simperator.com 
-</code> 
- 
- 
-端口分配的设置参考[[https://www.cyberciti.biz/faq/linux-unix-nginx-redirect-all-http-to-https/|Nginx Redirect HTTP To HTTPS]] / [[https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-with-ssl-as-a-reverse-proxy-for-jenkins|How To Configure Nginx with SSL as a Reverse Proxy for Jenkins]] 
- 
-**吊销证书**\\ 
-严格来说不需要吊销一个证书,除非自己已经对这个域名失去控制。只要删除证书就好,三个月后会自动过期。并且<color #ff7f27>''%%revoke%%''</color>命令也不会删除,下次renew的时候还是会被更新。 
 <code> <code>
-certbot delete --cert-name MyDomain+sudo iptables -P INPUT ACCEPT 
 +sudo iptables -P OUTPUT ACCEPT 
 +sudo iptables -P FORWARD ACCEPT 
 +sudo iptables -F // 清除所有的已订定的规则 
 +sudo iptables -X 
 +sudo iptables -Z
 </code> </code>
  
-== sslforfree == 
- 
-另外一种申请证书的方式 [[https://www.sslforfree.com/|免费ssl证书]] 
-====== SSL 更新 ====== 
-更新证书遇到错误: 
-<code> 
-sudo certbot renew --dry-run 
- 
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-Processing /etc/letsencrypt/renewal/simperator.com.conf 
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-Failed to renew certificate simperator.com with error: The manual plugin is not working; there may be problems with your existing configuration. 
-The error was: PluginError('An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.') 
- 
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-All renewals failed. The following certificates could not be renewed: 
-  /etc/letsencrypt/live/simperator.com/fullchain.pem (failure) 
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-1 renew failure(s), 0 parse failure(s) 
-Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details. 
-</code> 
- 
-尝试新的命令 
-<code | download> 
-certbot certonly --manual -d *.simperator.com 
-</code> 
- 
-更新证书后要重启服务器 <color #ff7f27>''%%sudo systemctl restart nginx%%''</color> 
- 
-将 <color #ff7f27>''%%/etc/letsencrypt/archive/simperator.com/*.pem%%''</color> 文件拷贝到第二台计算机上,<color #ff7f27>''%%ln -s%%''</color> 命令更新软链接,就可以在新的计算机上使用此证书。  
- 
-為了防止過多的 TXT 紀錄,以後要刪除舊的紀錄。ionos 1小時, pi server 2小時。 
  
-buypass TLS 证书可以6个月有效 
-    certbot certonly --standalone --agree-tos -d www.simperator.com -d simperator.com --server https://api.buypass.com/acme/directory 
  
  
 ====== ACME 证书 ====== ====== ACME 证书 ======
  
 +++++ 不再使用的方法 |
 [[https://wsgzao.github.io/post/acme/|ACME 证书申请讲解]] [[https://wsgzao.github.io/post/acme/|ACME 证书申请讲解]]
  
行 157: 行 68:
 apt install -y socat apt install -y socat
 curl  https://get.acme.sh | sh curl  https://get.acme.sh | sh
-~/.acme.sh/  // 安装到自己目录下+// ~/.acme.sh/  // 安装到自己目录下
 </code> </code>
 +
 +直接在Termial创建一个别名,可以方便使用 <color #ff7f27>''%%alias acme.sh=~/.acme.sh/acme.sh%%''</color>
  
 注册证书 注册证书
行 207: 行 120:
 include /etc/nginx/default.d/*.conf; include /etc/nginx/default.d/*.conf;
 </code> </code>
 +++++
  
-查看证书 <wrap em>acme.sh list</wrap> 有效日期+查看证书 <wrap em>acme.sh list</wrap> 有效日期, [[https://github.com/acmesh-official/acme.sh|acme.sh Github项目]]
  
-<WRAP center round important 60%>+<WRAP left round important 60%>
 cloudflare 现在已经不支持通过API设置.cf, .ga, .gq, .ml, 或.tk域名的DNS记录,在acme.sh设置TXT记录时会出错。只能单个证书申请。 cloudflare 现在已经不支持通过API设置.cf, .ga, .gq, .ml, 或.tk域名的DNS记录,在acme.sh设置TXT记录时会出错。只能单个证书申请。
 </WRAP> </WRAP>
  
 +
 +freenom 的域名以后用CF的源服务器证书就好,10年有效。但 CF 自己的证书不被其它地方认证,无法在后台订阅服务中使用。网站的后台服务如果需要ssl证书,就使用 .com 或者 .eu.org 域名,使用 acme.sh ecc 签署。
  
 ===== cloudflare ===== ===== cloudflare =====
  
-托管在 cloudflare 上的域名参考 [[https://blog.augustdoit.men/acme/|用 acme.sh 脚本申请 SSL 证书并自动更新]] 以及 [[https://www.zatp.com/post/auto-update-ssl-with-acme/|使用 acme.sh 自动签发和更新证书]]+托管在 cloudflare 上的域名参考 [[https://blog.augustdoit.men/acme/|用 acme.sh 脚本申请 SSL 证书并自动更新]] 
  
 定时任务更新证书,并重新加载 nginx  定时任务更新证书,并重新加载 nginx 
行 240: 行 156:
  
      
-{{tag>vps ubuntu}}+{{tag>vps ubuntu acme}}
it/server/security.1660383842.txt.gz · 最后更改: 2022-08-13 09:44 由 goldentianya
回到顶部
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0