制作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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • webpack处理less的loader_登录器和引擎版本号不匹配

    webpack处理less的loader_登录器和引擎版本号不匹配Theremightbeaproblemwiththeprojectdependencytree.ItislikelynotabuginCreateReactApp,butsomethingyouneedtofixlocally.Thereact-scriptspackageprovidedbyCreateReactApprequiresadependency:”webpack”:”4.44.2″Don’ttryt

    2022年8月9日
    32
  • 事务的四种隔离级别_事务默认的隔离级别

    事务的四种隔离级别_事务默认的隔离级别数据库事务的隔离级别有4种,由低到高分别为Readuncommitted、Readcommitted、Repeatableread、Serializable。Readuncommitted读未提交,顾名思义,就是一个事务可以读取另一个未提交事务的数据。事例:老板要给程序员发工资,程序员的工资是3.6万/月。但是发工资时老板不小心按错了数字,按成3.9万/月,该钱已经打到程序员的户口,

    2022年10月14日
    2
  • 定时任务cron表达式使用详解

    定时任务cron表达式使用详解项目中有时会需要定时去触发一些任务 Java 实现定时任务一般有三种方法 JDK 自带的 Timer 以及 JDK1 5 新增的 ScheduledExe Quartz 定时器 简单却强大的 JAVA 作业调度框架 Spring3 0 以后自带的 task 任务调度 可以将它看成一个轻量级的 Quartz 而且使用起来比 Quartz 简单许多 这里不去细谈三种定时任务实现的原理 可以自行去百度查看 下面主要说一下在设置定时任务时用到的 cron 表达式 Linux 系统中内置 cron 进程 通过 cron

    2025年6月3日
    2
  • virsh console 进不去虚拟机_virsh 命令

    virsh console 进不去虚拟机_virsh 命令参考自链接http://www.2cto.com/os/201411/354288.html下的文章,感谢作者,自己整理备份,以备查用。问题描述:       先执行命令virshstartmycentos,启动虚拟机。       当执行命令virshconsolemycentos后出现如下显示:       virshconsolemycentos

    2022年8月12日
    5
  • eclipse自动补全设置_eclipse补全设置

    eclipse自动补全设置_eclipse补全设置Eclipse版本问题描述自动补全显示顺序不尽人意,如下:输入equals使用自动补全后,显然并不是我们希望使用的方法。解决方法1进入Windows选项卡下的Perferences,搜索ContentAssist,找到Java选项卡下的ContentAssist,选择Advanced选项卡。将其中内容配置为(即,将上下两部分的JavaProposals(Task-Focused)取消勾选,将JavaProposals勾选);之后就可以开心的使用自动补全啦!解决方法2这是

    2022年10月15日
    2
  • Js判断数组中是否存在某个元素「建议收藏」

    Js判断数组中是否存在某个元素「建议收藏」方法一:indexOf(item,start);Item:要查找的值;start:可选的整数参数,缺省则从起始位子开始查找。indexOf();返回元素在数组中的位置,如果没有则返回-1;例子:vararr=[‘aaa’,’bbb’,’ccc’,’ddd’,’eee’];  vara=arr.indexOf(‘ddd’);  console.log(a);  //3  varb=arr.indexOf(‘d’);  console.log(b);  //-1  我通常的用法:if(

    2022年10月19日
    3

发表回复

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

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