当前位置:   article > 正文

如何使用OpenSSL创建私钥和公钥_.bin类型私钥

.bin类型私钥

如何使用OpenSSL创建私钥和公钥


一、安装OpenSLL,选择默认路径C:\OpenSSL-Win64\bin
下载Win64OpenSSL.exe

二、配置环境变量
复制路径:C:\OpenSSL-Win64\bin
打开Path目录,添加该路径

三、在bin目录创建private文件夹(存储生成的公钥)

四、打开CMD
注:CN=(名字与
姓氏), OU=(组织单位名称), O=(组织名称), L=(城市或区域名称), ST=(州或省份名称), C=(单位的两字母国家代码)

Microsoft Windows [版本 10.0.14393]
(c) 2016 Microsoft Corporation。保留所有权利。

C:\Users\Administrator>cd /

C:>cd C:\OpenSSL-Win64\bin

C:\OpenSSL-Win64\bin>openssl genrsa -out root.key 2048
Generating RSA private key, 2048 bit long modulus
….+++
………………………………+++
e is 65537 (0x010001)

C:\OpenSSL-Win64\bin>set OPENSSL_CONF=C:\OpenSSL-Win64\bin\openssl.cfg

C:\OpenSSL-Win64\bin>echo %OPENSSL_CONF%
C:\OpenSSL-Win64\bin\openssl.cfg

C:\OpenSSL-Win64\bin>openssl req -new -key root.key -out root.csr -subj “/C=CN/ST=ShangHai/L=ShangHai/O=Yunan International Trust Company/OU=Internet Finance/CN=YNTRUST”

C:\OpenSSL-Win64\bin>openssl x509 -req -days 3000 -sha1 -extensions v3_ca -signkey root.key -in root.csr -out root.cer
Signature ok
subject=C = CN, ST = ShangHai, L = ShangHai, O = Yunan International Trust Company, OU = Internet Finance, CN = YNTRUST
Getting Private key

C:\OpenSSL-Win64\bin>openssl genrsa -out private/server-key.pem 2048
Generating RSA private key, 2048 bit long modulus
…………+++
…………………………………………+++
e is 65537 (0x010001)

C:\OpenSSL-Win64\bin>openssl req -new -key private/server-key.pem -out private/server.csr -subj “/C=CN/ST=ShangHai/L=ShangHai/O=Yunan International Trust Company/OU=Internet Finance/CN=YNTRUST”

C:\OpenSSL-Win64\bin>openssl x509 -req -days 3000 -sha1 -extensions v3_req -CA root.cer -CAkey root.key -CAserial ca.srl -CAcreateserial -in private/server.csr -out private/server.cer
Signature ok
subject=C = CN, ST = ShangHai, L = ShangHai, O = Yunan International Trust Company, OU = Internet Finance, CN = YNTRUST
Getting CA Private Key

C:\OpenSSL-Win64\bin>openssl x509 -outform der -in private/server.cer -out private/publicserver.ccertificate.der

C:\OpenSSL-Win64\bin>openssl pkcs12 -export -in private/server.cer -inkey private/server-key.pem -out server.pfx
Enter Export Password:
Verifying - Enter Export Password:

C:\OpenSSL-Win64\bin>openssl rsa -in private/server-key.pem -pubout -outform PEM -out private/server-key-pub.pem
writing RSA key

图片示例:

这里写图片描述
这里写图片描述

另附SSL证书格式转换工具:https://www.chinassl.net/ssltools/convert-ssl.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/308204
推荐阅读
相关标签
  

闽ICP备14008679号