背景
Let’s Encrypt是一家全球证书颁发机构,由ISRG(Internet Security Research Group)创立,目的是简化网站的安全加密。Let’s Encrypt证书申请快速(只需要拥有域名)、免费、且支持泛域名证书,非常适用于个人网站、博客及一些简单的门户类网站。但由于只进行比较基础的域名验证,暂不支持OV(Organization Validation)、EV(Extended Validation)验证,证书有效期只有90天,因此大型或高安全级别的网站,比如购物、银行等,使用需要慎重。
本文谨记录项目开发过程中Let’s Encrypt证书的申请制作过程以及后续运维遇到的一些问题。
制作过程
域名
要申请制作一个SSL证书,首先要拥有此证书对应域名的控制权限,后续操作中需要新增域名记录用作验证。
Certbot客户端
对于可以进行shell命令行操作的用户来说,官方推荐使用certbot客户端来制作证书。
安装certbot
sudo apt update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install certbot python3-certbox-nginx
泛域名证书制作
certbot certonly -d *.abcd.com -d abcd.com --manual --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory
• 会提示输入邮箱,用于后续证书过期告警提示
• 在域名check环节,根据提示,需要在域名服务器上生成一条txt记录
dig -t TXT _acme-challenge.abcd.com可查看是否生效
• 最终会提示生成成功
• 生成的证书,默认存放路径在/etc/letsencrypt
相关问题
CAA报错
在证书制作过程中,遇到过CAA报错。
Press Enter to Continue Waiting for verification...
Cleaning up challenges
Failed authorization procedure. abcd.com (dns-01): urn:ietf:params:acme:error:dns :: DNS problem: SERVFAIL looking up CAA for abcd.com - the domain's nameservers may be malfunctioning, abcd.com (dns-01): urn:ietf:params:acme:error:dns :: DNS problem: SERVFAIL looking up CAA for abcd.com - the domain's nameservers may be malfunctioning
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: abcd.com
Type: None
Detail: DNS problem: SERVFAIL looking up CAA for abcd.com - the
domain's nameservers may be malfunctioning
Domain: abcd.com
Type: None
Detail: DNS problem: SERVFAIL looking up CAA for abcd.com - the
domain's nameservers may be malfunctioning
参考官网:https://letsencrypt.org/zh-cn/docs/caa/
在域名服务商增加CAA配置
Name Type Value
abcd.com. CAA 0 issue "letsencrypt.org"
0 issue "sectigo.com"
关于续租
由于本项目域名是在中万网购买的,其没有提供API接口用于配置TXT记录。但续租的时候需要用到–manual-auth-hook,这是通过脚本自动配置新的TXT值,当前域名的环境暂时不支持。在90天到期之前,重新进行证书制作,然后再把证书传至服务器上。