制作PFX证书

制作PFX证书1、创建根证书密钥文件root.keyC:\Users\lijunlin>opensslgenrsa-des3-outroot.keyGeneratingRSAprivatekey,2048bitlongmodulus…………………………………………………………….+++.+++eis65537(0x10001)Enterpassphraseforroot.k

大家好,又见面了,我是你们的朋友全栈君。

1、创建根证书密钥文件 root.key

C:\Users\wood>openssl genrsa -des3 -out root.key
Generating RSA private key, 2048 bit long modulus
…………………………………………………………….+++
.+++
e is 65537 (0x10001)
Enter pass phrase for root.key:
Verifying – Enter pass phrase for root.key:

2、创建根证书的申请文件root.csr

C:\Users\wood>openssl req -new -key root.key -out root.csr
Unable to load config info from ?:\*THERE_IS_NO_DEFAULT_DIRECTORY_SET_ENVIRONMENT_VARIABLES_INSTEAD*/?:\*THERE_IS_NO_DEFAULT_DIRECTORY_SET_ENVIRONMENT_VARIABLES_INSTEAD*/openssl.cnf

C:\Users\wood>set OPENSSL_CONF=C:/gnuwin32/share/openssl.cnf

C:\Users\wood>openssl req -new -key root.key -out root.csr
Enter pass phrase for root.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:cn
State or Province Name (full name) [Some-State]:hb
Locality Name (eg, city) []:wh
Organization Name (eg, company) [Internet Widgits Pty Ltd]:ours
Organizational Unit Name (eg, section) []:ours
Common Name (eg, YOUR name) []:li
Email Address []:

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

3、创建一个自当前日期起为期十年的根证书root.crt

C:\Users\wood>openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey root.key -in root.csr -out root.crt
Signature ok
subject=/C=cn/ST=hb/L=wh/O=ums/OU=ours/CN=li
Getting Private key
Enter pass phrase for root.key:

4、创建服务器证书密钥server.key

C:\Users\wood>openssl genrsa -out server.key 2048
Generating RSA private key, 2048 bit long modulus
……………………….+++
……………………..+++
e is 65537 (0x10001)

5、创建服务器证书的申请文件server.csr

C:\Users\wood>openssl req -new -key server.key -out server.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:cn
State or Province Name (full name) [Some-State]:hb
Locality Name (eg, city) []:wh
Organization Name (eg, company) [Internet Widgits Pty Ltd]:ours
Organizational Unit Name (eg, section) []:ours
Common Name (eg, YOUR name) []:li
Email Address []:

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

6、创建自当前日期起有效期为期两年的服务器证书server.crt

C:\Users\wood>openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in server.csr -out server.crt
Signature ok
subject=/C=cn/ST=hb/L=wh/O=ums/OU=ours/CN=li
Getting CA Private Key
Enter pass phrase for root.key:

7、创建客户端证书密钥文件client.key

C:\Users\wood>openssl genrsa -des3 -out client.key 2048
Generating RSA private key, 2048 bit long modulus
………………………………………………………………………………………………..+++
.+++
e is 65537 (0x10001)
Enter pass phrase for client.key:
Verifying – Enter pass phrase for client.key:

8、创建客户端证书的申请文件client.csr

C:\Users\wood>openssl req -new -key client.key -out client.csr
Enter pass phrase for client.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:cn
State or Province Name (full name) [Some-State]:hb
Locality Name (eg, city) []:wh
Organization Name (eg, company) [Internet Widgits Pty Ltd]:ours
Organizational Unit Name (eg, section) []:ours
Common Name (eg, YOUR name) []:li
Email Address []:

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

9、创建一个自当前日期起有效期为两年的客户端证书client.crt

C:\Users\wood>openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in client.csr -out client.crt
Signature ok
subject=/C=cn/ST=hb/L=wh/O=ums/OU=ours/CN=li
Getting CA Private Key
Enter pass phrase for root.key:

10、将客户端证书文件client.crt和客户端证书密钥文件client.key合并成客户端证书安装包client.pfx

C:\Users\wood>openssl pkcs12 -export -in client.crt -inkey client.key -out client.pfx
Enter pass phrase for client.key:
Enter Export Password:
Verifying – Enter Export Password:

11、保存生成的文件备用,其中server.crtserver.key是配置单向SSL时需要使用的证书文件,client.crt是配置双向SSL时需要使用的证书文件,client.pfx是配置双向SSL时需要客户端安装的证书文件

.crt文件和.key可以合到一个文件里面,把2个文件合成了一个.pem文件(直接拷贝过去就行了)

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/133883.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • poe交换机跟普通交换机的区别_以太网交换机和poe交换机的区别

    poe交换机跟普通交换机的区别_以太网交换机和poe交换机的区别众所周知电气设备只有通电后才能工作,而一些基于IP网络的各种设备也同样需要供电才能使用,自从有了poe供电技术后IP网络设备就又多了一种供电方式。那么具体poe工业以太网交换机可以当普通工业以太网交换机用吗,poe工业以太网交换机有哪些优势呢?poe工业以太网交换机可以当普通工业以太网交换机用吗poe工业以太网交换机的可以当作普通工业以太网交换机来用的,不过必要是正规厂商生成的支持802.3at/af协议的poe工业以太网交换机,因为这些poe工业以太网交换机在供电前会先提供1个低电压检测前..

    2022年10月5日
    0
  • c获取网卡序列号_win10查看序列号命令

    c获取网卡序列号_win10查看序列号命令privatevoidbutton1_Click(objectsender,EventArgse){textBox1.Text=””;foreach(stringsinlistBox1.SelectedItems){ManagementObjectSearchersearche…

    2022年10月2日
    0
  • Android busybox安装与vim Python IDE开发环境

    Android busybox安装与vim Python IDE开发环境在Android上安装BusyBox0.先要把手机给Root了,具体教程这里就不提供了,网上有很多。1.下载BusyBox的binary,打开这个地址 http://www.busybox.net/downloads/binaries 例如下载了:/downloads/binaries/1.21.1/中的busybox-armv7l2.把下载好的busybox-armv7l用

    2022年7月25日
    21
  • Java 安全之Weblogic 2017-3248分析

    Java安全之Weblogic2017-3248分析0x00前言在开头先来谈谈前面的绕过方式,前面的绕过方式分别使用了streamMessageImpl和MarshalledObject对

    2021年12月12日
    56
  • 修改pycharm镜像源「建议收藏」

    修改pycharm镜像源「建议收藏」国内的镜像源地址:阿里云:http://mirrors.aliyun.com/pypi/simple/中国科技大学:https://mirrors.bfsu.edu.cn/pypi/web/simple/豆瓣:http://pypi.doubanio.com/simple/清华:https://pypi.tuna.tsinghua.edu.cn/simple/网易:https://mirrors.163.com/pypi/simple/在pycharm中配置镜像源地址:…

    2022年8月27日
    3
  • 【java】异常处理[通俗易懂]

    【java】异常处理[通俗易懂]【java】异常处理

    2022年4月24日
    31

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号