Let’s Encrypt 签发ECC证书

椭圆曲线密码学(Elliptic curve cryptography,缩写为ECC),一种建立公开金钥加密的算法,基于椭圆曲线数学。椭圆曲线在密码学中的使用是在1985年由Neal Koblitz和Victor Miller分别独立提出的。

内置 ECDSA 公钥的证书一般被称之为 ECC 证书,内置 RSA 公钥的证书就是 RSA 证书。由于 256 位 ECC Key 在安全性上等同于 3072 位 RSA Key,加上 ECC 运算速度更快,ECDHE 密钥交换 + ECDSA 数字签名无疑是最好的选择。由于同等安全条件下,ECC 算法所需的 Key 更短,所以 ECC 证书文件体积比 RSA 证书要小一些。

ECC 证书不仅仅可以用于 HTTPS 场景当中,理论上可以代替所有 RSA 证书的应用场景,如 SSH 密钥登陆、SMTP 的 TLS 发件等。

购买证书需要的CSR请求用openssl创建csr和pkey方法:

1
2
$ openssl ecparam -out ecc.zmq100.cn.ecc.pkey -name prime256v1 -genkey 
$ openssl req -new -key ecc.zmq100.cn.ecc.pkey -sha256 -nodes -out ecc.zmq100.cn.ecc.csr -subj "/CN=ecc.zmq100.cn"

1、创建目录,到目录里。

1
$ mkdir ecc && cd ecc

2、下载acme.sh到本地

1
2
$ wget https://ghproxy.net/https://github.com/acmesh-official/acme.sh/blob/master/acme.sh
$ chmod +x acme.sh

3、切换签发的中间ca

1
2
3
# 默认是zerossl,一直有504,所以正常一般用 letsencrypt的ca,切换一下
> https://github.com/acmesh-official/acme.sh/wiki/Server
$ ./acme.sh --set-default-ca --server letsencrypt

4、签发证书

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 本案例用的运行模式是 Standalone,其他nginx、dns可能需要自己查一下,生成证书放到本地
# 需要注意的是,`本地80端口没有被占用的情况,且域名的A记录需要是本机的公网IP,能被外网访问的`
$ ./acme.sh --issue --standalone -w ./ -d ecc.zmq100.cn --keylength ec-256
$ ls /root/.acme.sh/ecc.zmq100.cn_ecc/* -l
-rw-r--r-- 1 root root 1567 9月 3 16:46 /root/.acme.sh/ecc.zmq100.cn_ecc/ca.cer # root ca证书
-rw-r--r-- 1 root root 1265 9月 3 16:46 /root/.acme.sh/ecc.zmq100.cn_ecc/ecc.zmq100.cn.cer # 服务端证书
-rw-r--r-- 1 root root 607 9月 3 16:46 /root/.acme.sh/ecc.zmq100.cn_ecc/ecc.zmq100.cn.conf
-rw-r--r-- 1 root root 460 9月 3 16:45 /root/.acme.sh/ecc.zmq100.cn_ecc/ecc.zmq100.cn.csr
-rw-r--r-- 1 root root 186 9月 3 16:45 /root/.acme.sh/ecc.zmq100.cn_ecc/ecc.zmq100.cn.csr.conf
-rw------- 1 root root 227 9月 3 16:17 /root/.acme.sh/ecc.zmq100.cn_ecc/ecc.zmq100.cn.key # 服务端证书key
-rw-r--r-- 1 root root 2832 9月 3 16:46 /root/.acme.sh/ecc.zmq100.cn_ecc/fullchain.cer # 包含中间证书和服务端的证书链

# CA证书参考这个地址:
https://letsencrypt.org/certificates/

参考文档:

https://www.wobushi.top/2022/https证书过期,acme超时问题处理/
https://developer.aliyun.com/ask/206634
还可以配置双证书: https://blog.mf8.biz/nginx-install-tls1-3/