最近在弄证书的东西,顺便把我了解的记录下.html
Let’s encrypt的免费证书已经出了快一年,之前弄了https的域名chrome还能送把绿的发亮的小绿锁呢,不过最近的版本更新已经撤销了这个小绿锁.python
sslabs这个网站可以检测ssl的安全、性能.在部署完以后能够去检测一下,ssllabs测试以后会给出一个评级,好比我目前就只有A,最高评分为A+. nginx
原本使用的是阿里云给的一年的单域名免费证书,但Let’s encrypt支持泛域名还免费,用脚🦶想都知道用哪一个.git
如何申请Let’s encrypt的证书呢?github
Let’s encrypt官方推荐cerbot来申请证书.按照官网教程一步一步走便可.下面演示的是ubuntu+nginx 的申请流程.chrome
①installshell
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-nginx
复制代码
运行完以上命令你便完成了cerbot的安装.接下来就是弄好dns的验证,弄好了这一步即可自动续期证书.ubuntu
②dns的验证插件dns-pluginapi
官方给出申请证书的命令以下:安全
$ sudo certbot -a dns-plugin -i nginx -d“* .example.com”-d example.com --server https://acme-v02.api.letsencrypt.org/directory
# dns-plugin,-nginx和example.com 是须要根据我的状况替换的.
# 对应的dns服务商有对应的dns插件,你能够在
# (https://certbot.eff.org/docs/using.html#dns-plugins )找到相关信息.
复制代码
我用的是dnspod,上述连接并不能给我提供帮助,因此用到了了第三库certbot-dns-dnspod
使用这个库以前,须要拿到dnspod生成的API Token.
生成路径:dnspod后台➡用户中心➡安全设置➡API Token➡建立API Token.
Dnspod这个token有个坑,务必注意上图信息中的 ID 和 Token,须要用这两个字段来组合成一个完整的 Token,组合方式为:"ID,Token"(用英文半角逗号分割)
So,完整的 Token 为:
13490,6b5976c68aba5b14a0558b77c17c3932
复制代码
回到本身的服务器,建立/etc/letsencrypt/dnspod.conf,会在拿证环节用到这个文件.
certbot_dns_dnspod:dns_dnspod_email = "xxxxx@qq.com"
certbot_dns_dnspod:dns_dnspod_api_token = "13490,6b5976c68aba5b14a0558b77c17c3932"
复制代码
③拿证!
sudo certbot certonly -a certbot-dns-dnspod:dns-dnspod --certbot-dns-dnspod:dns-dnspod-credentials /etc/letsencrypt/dnspod.conf --server https://acme-v02.api.letsencrypt.org/directory -d gongchen.com -d "*.gongchen.com"
复制代码
....自动续订啥的未完待续