标签: ssl

  • 网站免费ssl证书

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

    安装acme.sh

    curl https://get.acme.sh | sh -s email=xxx@xxx.com
    ource ~/.bashrc

    生成证书

    acme.sh --issue -d yourdomain.com --webroot /网站在服务器上的绝对路径

    安装证书

    acme.sh --install-cert -d yourdomain.com \
    --key-file       /new/path/to/xxx.key  \
    --fullchain-file /new/path/to/fullchain.cer \
    --ca-file        /new/path/to/ca.cer \
    --reloadcmd     "systemctl reload nginx"

    –key-file 私钥文件路径
    –fullchain-file 全链证书路径
    –ca-file CA证书路径
    –reloadcmd 证书更新后执行的命令(如重启Nginx)

    对应nginx配置里的:

    ssl_certificate         /new/path/to/fullchain.cer;
    ssl_certificate_key     /new/path/to/xxx.key;    
    ssl_trusted_certificate /new/path/to/ca.cer;

    acme.sh的cron任务(自动续期)会自动将新证书安装到上述指定的所有路径,无需手动干预。因此,只要初始安装命令正确,后续续期都会使用相同的路径。