自动续签免费ssl证书

1.安装acme.sh

acme官方文档链接:https://github.com/acmesh-official/acme.sh/wiki

acme官网git地址:https://github.com/acmesh-official/acme.sh

切换root:sudo su
curl https://get.acme.sh | sh -s email=你的邮箱

注意:安装完成后,再重新打开命令行(如果是 SSH,选择重新连接),以使acme.sh命令生效。

acme.sh -h 查看帮助,检测是否安装成功

2.对域名进行授权

进入ACM域名管理页面:https://freessl.cn/acme-deploy

点击添加 ==》填写域名和记录类型 》点击下一步获取DCV配置》去域名后台配置解析
在这里插入图片描述

3、获取证书申请部署命令

在这里插入图片描述

去命令行执行部署命令
执行后显示证书文件夹位置:

[Thu Nov 23 16:07:48 CST 2023] Your cert is in: /root/.acme.sh/xxx.com_ecc/admin.eimkt.com.cer
[Thu Nov 23 16:07:48 CST 2023] Your cert key is in: /root/.acme.sh/xxx.com_ecc/admin.eimkt.com.key
[Thu Nov 23 16:07:48 CST 2023] The intermediate CA cert is in: /root/.acme.sh/xxx.com_ecc/ca.cer
[Thu Nov 23 16:07:48 CST 2023] And the full chain certs is there: /root/.acme.sh/xxx.com_ecc/fullchain.cer

4、部署到 WebServer

配置Nginx

root@localhost:~# vim /etc/nginx/conf/example.com.conf
server {
  	listen 443 ssl http2;

    ssl_certificate    /www/server/panel/vhost/cert/example.com/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/example.com/privkey.pem;


}

安装域名证书到指定Nginx位置

root@localhost:~# acme.sh --install-cert -d example.com \
--key-file       /etc/nginx/ssl/example.com.key  \
--fullchain-file /etc/nginx/ssl/example.com.cer \
--reloadcmd     "nginx -s reload"

证书安全检测

网址:https://myssl.com/
也可以安装谷歌浏览器插件查看,安装地址:https://myssl.com/chrome_extension.html

查看已管理的域名

acme.sh --list

删除托管的域名

acme.sh --remove -d example.com [--ecc]

附录-申请颁发多个域名证书

示例:

acme.sh --issue -d example.com -d www.example.com -d cp.example.com -w /home/wwwroot/example.com

附录-将证书自动安装到Nginx或Apache

Apache示例:

acme.sh --install-cert -d example.com \
--cert-file      /path/to/certfile/in/apache/cert.pem  \
--key-file       /path/to/keyfile/in/apache/key.pem  \
--fullchain-file /path/to/fullchain/certfile/apache/fullchain.pem \
--reloadcmd     "service apache2 force-reload"

Nginx示例:

acme.sh --install-cert -d example.com \
--key-file       /path/to/keyfile/in/nginx/key.key  \
--fullchain-file /path/to/fullchain/nginx/cert.cer \
--reloadcmd     "service nginx force-reload"

附录-强制更新证书

我们通常不需要手动更新证书,所有证书每60天会自动更新一次。
但是也可以手动强制更新证书。
示例:

acme.sh --renew -d example.com --force

附录-设置默认使用的CA

参考文档:https://github.com/acmesh-official/acme.sh/wiki/Server
letsencrypt https://acme-v02.api.letsencrypt.org/directory
buypass https://api.buypass.com/acme/directory
zerossl https://acme.zerossl.com/v2/DV90
sslcom https://acme.ssl.com/sslcom-dv-rsa, https://acme.ssl.com/sslcom-dv-ecc

猜你喜欢

转载自blog.csdn.net/weixin_39105981/article/details/134576520
今日推荐