Skip to main content

SSL 证书

一、申请

certbot(letsencrypt) > acme.sh

使用 acme.sh 生成、更新证书

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

1. 安装

curl https://get.acme.sh | sh -s email=

2. 设置 ca

acme.sh --set-default-ca --server letsencrypt
acme.sh --set-default-ca --server google
acme.sh --set-default-ca --server zerossl

3. 生成证书

3.1 http 方式

http 方式需要在你的网站根目录下放置一个文件, 来验证你的域名所有权,完成验证. 然后就可以生成证书了.

acme.sh --issue -d example.com -d www.example.com -d xxx.example.com -w /home/wwwroot/example.com
3.2 dns 方式

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

acme.sh --issue --dns dns_cf -d 0x64.in

acme.sh --issue --dns dns_dp -d 0x64.in

⚠freenom 注册的域名不可以用 cloudflare dns

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

4. 安装证书

acme.sh --installcert -d example.com \
--key-file xxx \
--fullchain-file xxx \
--reloadcmd "service nginx force-reload"

二、续期

1. 自动续期

2. 手动续期

acme.sh --renew -d  example.com
### 强制
acme.sh --renew -d example.com --force

三、其他配置

生成迪菲-赫尔曼密钥以增强安全

openssl dhparam -out /etc/ssl/certs/dhparams.pem 2048

nginx 配置

https://ssl-config.mozilla.org/

四、验证

https://www.ssllabs.com/ssltest/