ssl证书之certbot

一.安装

1.下载压缩包:
#wget https://github.com/certbot/certbot/archive/master.zip

2.解压包

3.官方文档
https://github.com/certbot/certbot

 

二.创建证书

创建的证书有90天的有效期,过期后需要续期

1.创建单个证书
./certbot-auto certonly --webroot -w 网站目录 -d 域名

2.创建多个证书
./certbot-auto certonly --webroot -w 网站目录1 -d 域名1 -w 网站目录2 -d 域名2


ps:
如果出现超时,可以再次执行命令

 

三.使用(nginx示例)

在server段配置:
ssl on;
ssl_certificate "/etc/letsencrypt/live/domain.com/fullchain.pem"; #请根据实际路径
ssl_certificate_key "/etc/letsencrypt/live/domain.com/privkey.pem"; #请根据实际路径

 

四.常用命令

1.查看证书
./certbot-auto certificates

2.续期(更新证书)
#模拟更新证书
./certbot-auto renew --dry-run
#实际更新证书
./certbot-auto renew

#模拟更新单个证书
./certbot-auto renew --dry-run --cert-name domain.com
#实际更新单个证书
./certbot-auto renew --cert-name domain.com

3.吊销证书
./certbot-auto revoke --cert-path /etc/letsencrypt/live/domain.com/fullchain.pem

4.certbot-auto每次运行都需要更新,如果保持版本锁定,增加--no-self-upgrade

 

五.其他问题

如果遇到Installing Python packages...卡主并报错

新建

~/.pip/pip.conf

写入以下内容(目的是更换pip源)

[global]
index-url = https://pypi.doubanio.com/simple/

[install]
trusted-host=pypi.doubanio.com

  

更好的证书生成工具,免费一年

https://github.com/acmesh-official/acme.sh

 

posted @ 2019-01-29 11:50  rorshach  阅读(1183)  评论(0编辑  收藏  举报