使用certbot续期ssl证书renew时遇到问题

原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://blog.csdn.net/qq_19868745/article/details/72677709

遇到的问题如下:IMPORTANT NOTES:

 - The following errors were reported by the server:


   Domain: www.miling.online
   Type:   unauthorized
   Detail: Invalid response from
   http://www.miling.online/.well-known/acme-challenge/8IPPiMABwsHSwqSSTfZ5XMv7wD9sqXdO1pzOwFebdzg
   [2001:470:35:bf9::2]: 404


   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A record(s) for that domain
   contain(s) the right IP address.
[root@iZuf6istfz0zvz8dbdfyxxZ ~]# certbot-auto renew --force-renew
-bash: certbot-auto: command not found
[root@iZuf6istfz0zvz8dbdfyxxZ ~]# 
[root@iZuf6istfz0zvz8dbdfyxxZ ~]# 1
-bash: 1: command not found
[root@iZuf6istfz0zvz8dbdfyxxZ ~]# certbot renew --quiet
Attempting to renew cert from /etc/letsencrypt/renewal/www.miling.online.conf produced an unexpected error: Failed authorization procedure. www.miling.online (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.miling.online/.well-known/acme-challenge/o30LM-8eAdn4IB8vX96Aa1Xgs6Mwc-5QjJNQ8mjl_Ns [2001:470:35:bf9::2]: 404. Skipping.


All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/www.miling.online/fullchain.pem (failure)

1 renew failure(s), 0 parse failure(s)

最后查看了certbot的帮助


依次运行:

# service nginx stop

# certbot --force-renewal

# certbot certonly

# certbot renew --dry-run

# cerbot nginx start



需要注意的是service nginx stop/start,否则会出现问题


### 实现阿里云SSL证书的自动续期配置 #### 使用 Certbot 和 Aliyun CLI 进行 SSL 证书自动续期 为了实现阿里云 SSL 证书的自动续期,可以采用 `Certbot` 结合 `Aliyun DNS API` 的方式来完成这一过程。具体来说: 安装必要的工具包是第一步,在此过程中需要先部署 `aliyun cli` 工具以及 `certbot-dns-aliyun` 插件[^1]。 ```bash pip install --upgrade pip pip install certbot-dns-aliyun ``` 接着设置环境变量以便于后续操作中调用阿里云API接口所需的身份验证信息。 ```bash export ALIBABA_CLOUD_ACCESS_KEY="your-access-key" export ALIBABA_CLOUD_SECRET_KEY="your-secret-key" ``` 申请新的 SSL 证书可以通过执行如下命令来进行,这里指定了域名解析服务商为阿里云DNS,并设置了相应的参数用于指定要保护的具体域名单元。 ```bash certbot certonly \ --dns-aliyun \ --dns-aliyun-propagation-seconds 60 \ -d example.com -d www.example.com ``` 对于已经存在的证书文件夹路径 `/etc/letsencrypt/live/example.com/` 下面包含了私钥和公钥等重要资料,这些都将被用来配合Nginx或其他Web服务器软件一起工作以提供HTTPS服务支持。 为了让整个流程更加自动化,还可以编写一个简单的脚本来定期检查并尝试更新现有的SSL证书。通常情况下会将此类任务安排到系统的定任务计划当中去执行,比如Linux下的Cron Jobs就是一种非常方便的选择之一。 编辑crontab文件加入下面这行代码可以让系统每天凌晨两点钟自动检测是否有可用的新版证书可供替换旧版本使用。 ```bash 0 2 * * * /usr/bin/certbot renew --quiet && systemctl reload nginx ``` 上述命令不仅实现了对Let's Encrypt颁发给我们的短期有效期SSL凭证的有效管理;同也确保了当有新版本发布能及获取最新安全补丁从而更好地维护站点安全性。 最后需要注意的是自2023年起,阿里云官方已将其所提供的免费型SSL产品生命周期缩短至90天以内,因此建议广大开发者朋友们尽早规划好各自的证书轮换策略以免影响线上业务正常运转[^2]。 通过以上介绍的方法,可以有效地简化SSL证书管理和维护的工作量,提高效率的同也增强了网站的安全防护能力[^3]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值