制作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文件(直接拷贝过去就行了)

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • dos环境下操作mysql

    dos环境下操作mysqldos环境下操作mysql

  • k8s中Evicted pod 是如何产生的

    k8s中Evicted pod 是如何产生的文章目录事件背景分析被驱逐的原因节点资源不足导致实例被驱逐kubelet驱逐Pod时与资源处理相关的已知问题驱逐Pod未被删除原因分析解决方案结语事件背景最近在线上发现很多Pod处于Evicted状态,通过podyaml可以看到实例是因为节点资源不足被驱逐,但是这些pod并没有被自动清理,平台的大部分用户在操作时看到服务下面出现EvictedPod时会以为服务有问题或者平台有问题的错觉,影响了用户的体验。而这部分Evicted状态的Pod在底层关联的容器其实已经被销毁了,对用户的

  • kettle工具使用教程_开源etl工具kettle

    kettle工具使用教程_开源etl工具kettlekettle工具使用简明手册运行启动脚本spoon.bat快捷方式如果正确启动,则出现的主界面应该是下面这样的。初次进入需右键新建作业新建数据库连接也可以想下面一样,新建数据库连接向导填完参数测试一下连接通过向导分步来我已经建立了转换任务和数据库连接,可以直接应用。 建立多表复制点击开始即可,多表的…

  • 数据挖掘十大经典算法(包括各自优缺点 / 适用数据场景)

    数据挖掘十大经典算法(包括各自优缺点 / 适用数据场景)本文主要分析皆来自其他资料,借用较为权威的总结来对我已经学习的这些经典算法做一个极为精简的概述(根据自身经验有一定修改),另外同时附上机器学习实战中作者对各种算法的评价。另外机器学习实战这本书是本人看了这么多书籍或者资料中唯一一本坚持从头看到尾,看完了的书籍,包括其中的代码皆实践运行过,收获颇多,个人认为虽然这本书时间上已经算是老资料了,但其中作者的各种总结和代码的演练都由浅入深(前提还是要有一点…

  • python+opencv图像模板匹配—多模板匹配

    python+opencv图像模板匹配—多模板匹配

  • IDEA惊天bug:进程已结束,退出代码-1073741819 (0xC0000005)[通俗易懂]

    IDEA惊天bug:进程已结束,退出代码-1073741819 (0xC0000005)[通俗易懂]由于昨天要写的文章没有写完,于是今天早上我四点半就“自然醒”了,心里面有事,睡觉也不安稳。洗漱完毕后,我打开电脑,正襟危坐,摆出一副要干架的态势,不能再拖了。要写的文章中涉及到一串代码,关于Undertow的一个入门示例,贴出来大家看一下。publicclassUndertowTest{publicstaticvoidmain(finalString[]args)…

发表回复

您的电子邮箱地址不会被公开。

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