SSL证书

烂柯 发布于 2023-06-16 103 次阅读


一、acme.sh颁发证书

1、acme.sh

acme.sh 实现了 acme 协议, 可以从 letsencrypt 生成免费的证书。官方文档 支持多种模式,本文记录的NDS手动模式创建泛域名证书(泛域名证书最好在Linux系统中生成)。

2、下载

wget https://github.com/acmesh-official/acme.sh/archive/refs/tags/3.0.6.tar.gz

3、生成证书

#1、设置默认CA https://github.com/acmesh-official/acme.sh/wiki/Change-default-CA-to-ZeroSSL
acme.sh --set-default-ca --server letsencrypt
#2、dns手动模式
acme.sh --issue --dns -d *.test.com  --keylength ec-256 --yes-I-know-dns-manual-mode-enough-go-ahead-please
#将 TXT 记录添加到您的 DNS 记录中
acme.sh --renew --dns -d *.test.com  --keylength ec-256  --yes-I-know-dns-manual-mode-enough-go-ahead-please
#3、根据所需转换证书格式
openssl pkcs12 -export -out test.com.pfx -inkey \*.test.com.key -in \*.test.com.cer

keylength参数如下:
ec-256(prime256v1,“ECDSA P-256”)
ec-384(secp384r1,“ECDSA P-384”)
ec-521(secp521r1,“ECDSA P-521”,Let’s Encrypt 尚不支持。)

4、更新证书

#强制更新证书:
acme.sh --renew -d *.swqyun.com  --dns  --force --yes-I-know-dns-manual-mode-enough-go-ahead-please

#停止或删除更新证书
acme.sh --remove -d *test.com [--ecc]
rm -rf ~/.acme.sh/\*test.com

二、本地证书

mkcert创建开发证书

mkcert -install
#创建pfx证书
mkcert -pkcs12 localhost

三、转换格式

pem转pfx

openssl pkcs12 -inkey test.com.key -in test.pem  -export -out test.pfx -passout pass:password
烂柯

最后更新于 2023-09-18