bithulu's blog

Posted Wed, 19 Oct 2016

免费好用的SSL证书Let's Encrypt

Let’s Encrypt推出免费可自动更新的SSL证书,使用起来很简单:

安装工具

$ git clone https://github.com/letsencrypt/letsencrypt
$ cd letsencrypt
$ ./letsencrypt-auto --help

申请和部署证书

Apache(httpd):

# ./letsencrypt-auto --apache -d yourdomain.com -d www.yourdomain.com -d foo.yourdomain.com

-d 后面是域名,可以是二级域名,可以有多个。 后面按提示操作。

Nginx:

# ./letsencrypt-auto certonly --webroot -w /usr/share/nginx/html -d yourdomain.com -d www.yourdomain.com -d foo.yourdomain.com

/etc/letsencrypt/live/yourdomain.com 目录下会生成下面文件:

ls -l会发现这只是几个文件链接。

nginx配置ssl配置关键部分:

ssl_certificate      /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key  /etc/letsencrypt/live/yourdomain.com/privkey.pem;

更多nginx ssl配置可参考wordpress相关文档https://codex.wordpress.org/Nginx

证书目前有限期是三个月,可以通过脚本自动更新,更新后延长期限也是3个月

使用下面命令自动renew证书并只在renew成功后restart nginx(会有downtime)

# ./letsencrypt-auto renew --renew-hook "service nginx restart"

加入上面加入cron,每两月执行一次,仅仅开到期时renew才会成功!

兼容性

已兼容

可能不兼容

不兼容

官方详细说明:https://letsencrypt.org/docs/certificate-compatibility/

使用限制

使用限制主要是一定时间内的申请量限制,还有就是一个证书最多100个子域名,一般个人使用不会超出限制,详见:https://letsencrypt.org/docs/rate-limits/, 但需要注意的是,一旦超出限制,只有等下一个周期恢复配额后再申请,Let's Encrypt没有开什么后门!

Category: 资源
Tags: ssl nginx apache https