关于Let’s Encrypt这个不需要过多的介绍了,这一样的也是作为记录性的文。
 通过Let’s Encrypt申请证书的方法有很多种,可以在ACME Client Implementations获取更多的信息。
官方推荐的是Certbot,通过选择自己的web服务器以及运行的操作系统后,简单的几条命令即可申请到证书了。
通过Let’s Encrypt申请证书的方法有很多种,可以在ACME Client Implementations获取更多的信息。
官方推荐的是Certbot,通过选择自己的web服务器以及运行的操作系统后,简单的几条命令即可申请到证书了。
但我还是选择了acme.sh,各有所爱吧。
前期准备工作
域名api
我的域名托管在Cloud XNS,需要到“用户中心”-“API管理”页面获取账户的API
类似于
| 1
2
 | API KEY:	xxxx8a66592b7efc0fd2986fe8dfxxxx
SECRET KEY:	xxxxe3422a53xxxx
 | 
 
安装acme.sh
我选择从GitHubgit clone高级安装
|  1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 | [ ! -d /srv/www/ssl/ ] ; mkdir -p /srv/www/ssl
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install  \
--home ~/.acme.sh \
--config-home ~/.acme.sh/data \
--certhome  /srv/www/ssl \
--accountemail  "[email protected]" \
--accountkey  /srv/www/ssl/myaccount.key \
--accountconf /srv/www/ssl/myaccount.conf \
--useragent  "this is my client."
 | 
 
脚本添加api
脚本的路径在~/acme.sh/dnsapi,Cloud XNS的脚本为dns_cx.sh
修改这个文件,将自己的API以及SECRET的key替换为自己的,并取消语句的注释。
申请证书
一般的,我们可以通过CSR文件在线生成工具进行csr文件的创建,在命令行可以通过如下命令进行csr文件生成。
| 1
2
 | openssl ecparam -genkey -name secp256r1 | openssl ec -out ecc.key
openssl req -new -key ecc.key -out ecc.csr
 | 
 
而acme.sh只需要执行如下命令即可:
acme.sh --issue --dns dns_cx -d *.lvmoo.com -k ec-256
分别会打印出站点证书、证书密钥、CA证书、补齐了CA根证书的站点证书。
| 1
2
3
4
 | Your cert is in  /srv/ssl/data/*.lvmoo.com_ecc/*.lvmoo.com.cer
Your cert key is in  /srv/ssl/data/*.lvmoo.com_ecc/*.lvmoo.com.key
The intermediate CA cert is in  /srv/ssl/data/*.lvmoo.com_ecc/ca.cer
And the full chain certs is there:  /srv/ssl/data/*.lvmoo.com_ecc/fullchain.cer
 | 
 
吊销证书
如果申请好的证书不需要了,可以手动进行吊销
| 1
 | acme.sh --revoke -d *.lvmoo.com --ecc
 |