访问 OpenSSL 的官方 Windows 版本下载页面:
https://slproweb.com/products/Win32OpenSSL.html
1. 生成私钥文件 (private.pem
):
openssl genpkey -algorithm RSA -out private.pem
这将生成一个 RSA 格式的私钥文件 private.pem
。
2. 生成证书签名请求(CSR
):
openssl req -new -key private.pem -out request.csr
在生成过程中,你会被要求输入一些证书信息,例如国家、组织等。
3. 生成自签名证书 (certificate.pem
):
openssl x509 -req -in request.csr -signkey private.pem -out certificate.pem -days 365
这将使用你的私钥 private.pem
来签署 CSR
文件,从而生成一个有效期为 365 天的自签名证书 certificate.pem
。
4. 生成证书指纹
openssl x509 -in certificate.pem -noout -fingerprint -sha256
如果成功,你将会在控制台中看到类似如下内容的输出
sha256 Fingerprint=8F:BB:A3:93:58:3A:F5:57:6E:63:3E:99:F4:47:25:2A:92:6C:3D:4F:6A:57:02:51:1B:7F:27:5B:1F:1C:76