LetsEncrypt免费SSL证书续期
Let's Encrypt 默认情况下只提供三个⽉的有效期,在有效期剩余半个⽉的时候,Let's Encrypt 会发送邮件给你,提醒你需要做证书的续期操作。
⼀、验证域名⽂件剩余有效期:
可以通过以下命令查看证书的剩余有效期限:
# /usr/local/letsencrypt/certbot-auto certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
Certificate Name: test
Serial Number: 43767e5d8b5768b451f49dc6d2898caf9c4
Domains: *.test test
Expiry Date: 2020-09-09 08:06:12+00:00 (VALID: 6 days)
Certificate Path: /etc/letsencrypt/live/test/fullchain.pem
Private Key Path: /etc/letsencrypt/live/test/privkey.pem
Certificate Name: st
Serial Number: 309acc59b6d1526c6f219b3708b92f10c9a
Domains: *.st
Expiry Date: 2020-01-22 10:08:05+00:00 (INVALID: EXPIRED)
Certificate Path: /etc/letsencrypt/st/fullchain.pem
Private Key Path: /etc/letsencrypt/st/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
⼆、域名续期:
1、直接续期:
Let's Encrypt 有多种验证⽅式,常⽤的有 http 和 dns ⽅式,如果服务器运⾏在本机的话,可以采⽤http⽅式验证,直接执⾏renew命令
# /usr/local/letsencrypt/certbot-auto renew --force-renewal
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/f
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Could not choose appropriate plugin: 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.',)
Attempting to renew cert (test) from /etc/letsencrypt/f produced an unexpected 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.',). Skipping.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2、脚本认证⽅式续期:
上边的报错信息是因为验证域名所有者失败,没有指定 --manual-auth-hook 参数。
由于是在另外⼀台机器⾥⾯申请的证书,⽆法使⽤ http ⽅式,所以之前申请证书⽤的是 dns ⽅式,也就是创建 TXT 记录。
如果是⽤DNSpod的域名解析,可以通过第三⽅的脚本实现dns⾃动验证功能,⽤其它服务商的也会有对应的脚本。
github/al-one/certbot-auth-dnspod
# /usr/local/letsencrypt/certbot-auto certonly -d *.test -d test --manual --preferred-challenges dns-01 --email admin@test --server acme-v02./directory --manual-auth-hook /path/to/certbot-auth-dnspod.sh 或者:
/usr/local/letsencrypt/certbot-auto renew --manual-auth-hook /path/to/certbot-auth-dnspod.sh
3、⼿动续期:
创建第三⽅脚本需要⽤的DNS服务商的令牌服务,这个不太容易实现,所以只能⽤⼿动续期的⽅式实现(就是⽣成⼀个新的key⽂件来覆盖旧的⽂件)。
# /usr/local/letsencrypt/certbot-auto certonly -d *.test -d test --manual --preferred-challenges dns --email admin@test --server acme-v02./directory
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Cert is due for renewal,
Renewing an existing certificate
Performing the following challenges:
dns-01 challenge for test
dns-01 challenge for test
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.
Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_st with the following value:
t-75JK_JaXlaZ5IC5b7kWsDJ9weqUo2aL-qlXAdq_Zc
Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_st with the following value:
ovibUqBSGf3ayBgYZAzS99ugUAHetyl2fC-bodaEJ2Y
Before continuing, verify the record is deployed.
(This must be set up in addition to the previous challenges; do not remove,
replace, or undo the previous challenge tasks yet. Note that you might be
asked to create multiple distinct TXT records with the same name. This is
permitted by DNS standards.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
中间要经历2次域名解析验证,按照提⽰添加域名TXT记录。
打开你的域名提供商,添加⼀条TXT类型的记录。
主机记录是上⾯打印出来的 _st 记录值为 t-75JK_JaXlaZ5IC5b7kWsDJ9weqUo2aL-qlXAdq_Zc 。
填写完毕之后,验证域名TXT记录是否⽣效:
# dig -t txt _st @8.8.8.8
;
<<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> -t txt _st @8.8.8.8 ;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53987
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;_st. IN  TXT
;; ANSWER SECTION:
_st. 599 IN TXT "t-75JK_JaXlaZ5IC5b7kWsDJ9weqUo2aL-qlXAdq_Zc" _st. 599 IN TXT "ovibUqBSGf3ayBgYZAzS99ugUAHetyl2fC-bodaEJ2Y" ;; Query time:
1190 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Sep 04 14:14:39 CST 2020
;; MSG SIZE  rcvd: 168
或者:
λ nslookup -qt=txt
默认服务器:  public1.alidns
Address:  223.5.5.5
> _st
服务器:  public1.alidns
Address:  223.5.5.5
免费ssl证书永久生成
⾮权威应答:
_st    text =
"t-75JK_JaXlaZ5IC5b7kWsDJ9weqUo2aL-qlXAdq_Zc"
_st    text =
"ovibUqBSGf3ayBgYZAzS99ugUAHetyl2fC-bodaEJ2Y"
验证TXT⽣效后,回车继续。
Waiting
Cleaning up challenges
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/test/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/test/privkey.pem
Your cert will expire on 2020-09-09. To obtain a new or tweaked
version of this certificate in the future, simply run certbot-auto
again. To non-interactively renew *all* of your certificates, run
"certbot-auto renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt:  /donate
Donating to EFF:                    /donate-le
⾄此域名验证key⽣成完毕。
三、重启nginx服务使配置⽣效:
拷贝key⽂件⾄/usr/local/nginx/conf/ssl/test
重新加载nginx配置⽂件⽣效
# /usr/local/nginx/sbin/nginx -s reload
⾄此证书续期完成。
[THE END]

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。