32

解决 certbot 无法更新证书问题

 4 years ago
source link: https://azhuge233.com/%e8%a7%a3%e5%86%b3-certbot-%e6%97%a0%e6%b3%95%e6%9b%b4%e6%96%b0%e8%af%81%e4%b9%a6%e9%97%ae%e9%a2%98/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
解决 certbot 无法更新证书问题

下文并没有根本上解决端口绑定的问题,只是换了一种获取/更新证书的方式,绕过了端口绑定

  • certbot
  • Ubuntu 16.04

certbot 更新证书,执行

certbot renew --dry-run
certbot renew --dry-run

Encountered exception during recovery: certbot.errors.MisconfigurationError: nginx restart failed:

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

nginx: [emerg] still could not bind()

Attempting to renew cert (xxx.com) from /etc/letsencrypt/renewal/xxx.com.conf produced an unexpected error: nginx restart failed:

解决 certbot 无法更新证书问题

参考太多了,不整理了

说法不一,一共两种理解(本人理解并不透彻,还需要进一步分析 certbot 的运行方式):

  1. certbot 使用了 standalone 的验证模式,验证时需要开启一个单独的 (nginx)webserver,而运行中的网站已经开启了 nginx 并绑定了 80、443 端口,导致 certbot 的 webserver 无法绑定端口 -> 无法完成验证 -> 无法更新证书
    • 如果先关闭网站的 nginx,网站则无法运行,后续 certbot 会访问网站的 .well-known 目录来验证网站管理权限,这时又会报错无法访问 .well-known/acme-challenge
  2. certbot 更新完证书后,无法重启 nginx,所以产生了 nginx restart failed 错误
    • 通过 –pre-hook 和 –post-hook 参数调整 nginx 关闭/开启命令后,仍然报相同错误
    • 不了解这两个参数可以自行百度,作用为自定义 certbot 更新证书前/后执行的指令

因为我只是想定期自动更新 let’s encrypt 证书,没有其他需求,所以最终选择使用 webroot 的验证方式,这样 certbot 就不会启动 webserver,从而解决报错问题

  1. 命令行执行,测试更新证书
    certbot certonly --dry-run -n --webroot -d 你的域名.com -d www.你的域名.com --webroot-path /你的/网站/目录
    certbot certonly --dry-run -n --webroot -d 你的域名.com -d www.你的域名.com --webroot-path /你的/网站/目录
  2. 去掉 –dry-run 更新证书
    certbot certonly -n --webroot -d 你的域名.com -d www.你的域名.com --webroot-path /你的/网站/目录
    certbot certonly -n --webroot -d 你的域名.com -d www.你的域名.com --webroot-path /你的/网站/目录
  3. 编辑 /etc/cron.d/certbot,更新 renew 命令解决 certbot 无法更新证书问题

解决 certbot 无法更新证书问题

解决 certbot 无法更新证书问题


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK