详解 https 证书 openssl 公钥私钥和 ssh 公钥私钥的生成和使用 -2. 在 windows 客户端通过 openssl 命令生成
最编程
2024-04-27 18:00:58
...
下面是生成自签名证书,仅为测试使用,需要在访问者浏览器导入自己生成的ca根证书。生产环境请像ca申请证书。 下面红色文字其实就是我们像ca申请证书我们需要做的,黑色部分是ca实现,并且ca的私钥自己保存不会泄露给第三方,ca用私钥生成的带签名证书会内置到浏览器里面。
// 生成服务器端私钥
openssl genrsa -out server.key 2048
//生成服务端公钥
openssl rsa -in server.key -pubout -out server.pem
//生成CA私钥
openssl genrsa -out ca.key 2048
//生成ca的csr文件
openssl req -config "F:\greensoft\openssl\openssl.cnf" -new -key ca.key -out ca.csr
//生成ca的自签名证书
openssl x509 -req -in ca.csr -signkey ca.key -out ca.crt
//生成server.csr文件
openssl req -config "F:\greensoft\openssl\openssl.cnf" -new -key server.key -out server.csr
//生成带有ca签名的证书
Openssl x509 -req -days 365 -sha256 -CA ca.crt -CAkey ca.key -CAcreateserial -in server.csr -out server.crt