»
(001)免费的https证书
本文参考了CSDN等网站的大量文章。
GoDaddy是一个免费的SSL证书更新网站,可以提供免费的证书申请。Let's Encrypt、Buypas、ZeroSSL、SSL.com是免费的证书登记网站。
证书相关的详细技术内容此处略过。这里要讲的是如何节省每年少则五六百多则一千多块的个人证书申请费用。废话不多说,下面是步骤:
(1)到developer.godaddy.com注册免费的开发者账号
(2)在developer.godaddy.com申请API Key,申请时,选择环境为生产环境(Enviroment: Production)
(3)到你的Linux服务器上安装acme.sh(https://gitee.com/neilpang/acme.sh)
curl https://get.acme.sh | sh
...
Install success!
(4)升级脚本
acme.sh --upgrade
(5)配置脚本的启用自动更新:
acme.sh --upgrade --auto-upgrade
禁用自动更新的脚本为:
acme.sh --upgrade --auto-upgrade 0
(6)切换证书登记网站:
切换 Let's Encrypt(推荐)
acme.sh --set-default-ca --server letsencrypt
切换 Buypass
acme.sh --set-default-ca --server buypass
切换 ZeroSSL
acme.sh --set-default-ca --server zerossl
切换 SSL.com
acme.sh --set-default-ca --server ssl.com
(7)设置在developer.godaddy.com申请的Key和Secret到环境变量。此设置只需要在调用acme.sh之前设置一次,运行acme.sh后脚本会自动保存设置。
将在developer.godaddy.com创建的API Key和Secret贴上并执行:
export GD_Key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export GD_Secret="xxxxxxxxxxxxxxxxxxxxxxxxxxx"
使用邮箱一次使用失败后86400秒内无法再次使用,需要更新注册邮箱:acme.sh --register-account -m 邮箱地址
(8)调用:acme.sh --issue -d v-signon.com --webroot /root/vso-www/
此方式acme.sh会让GoDaddy服务器验证你的域名是否能够访问。也就是,脚本会在你的网站根目录下放置一个文件,然后让服务器来验证你的域名是否可以访问。如果能够访问,GoDaddy就认为这个域名和你的GoDaddy账户是对应的。运行完成脚本会自动下载证书文件:
[Fri Jun 28 12:11:53 CST 2024] Your cert is in: /root/myacme/ssl/v-signon.com_ecc/v-signon.com.cer
[Fri Jun 28 12:11:53 CST 2024] Your cert key is in: /root/myacme/ssl/v-signon.com_ecc/v-signon.com.key
[Fri Jun 28 12:11:53 CST 2024] The intermediate CA cert is in: /root/myacme/ssl/v-signon.com_ecc/ca.cer
[Fri Jun 28 12:11:53 CST 2024] And the full chain certs is there: /root/myacme/ssl/v-signon.com_ecc/fullchain.cer
需要注意的是,GoDaddy对服务器的验证通过你的服务器的80端口的http服务验证。
(9)配置你的nginx中的ssl服务,注意443端口后面一定要跟上ssl关键词。
listen 443 ssl;
listen [::]:443 ssl;
server_name v-signon.com;
ssl_certificate /root/myacme/ssl/v-signon.com_ecc/v-signon.com.cer;
ssl_certificate_key /root/myacme/ssl/v-signon.com_ecc/v-signon.com.key;
(10)新建777脚本/root/do-acme.sh,脚本内容为:
#!/bin/bash
alias acme.sh=/root/myacme/acme.sh
acme.sh --renew-all --force --reloadcmd "/usr/sbin/nginx -s reload"
(11)起用Linux的crond定时服务,并去掉默认的acme代码,加入以下代码:
0 0 28 */3 * /root/do-acme.sh
注意:Let's Encrypt的免费SSL证书部署后,只能支持桌面浏览器的安全访问。部分手机以及微信对Let's Encrypt的免费SSL证书支持不友好。
————www.v-signon.com学习者共勉