自签名多级证书亲测可用
rem 不能使用jdk1.7
set JAVA_HOME=E:\tools\java\jdk1.8.0_181x64
set PATH=%JAVA_HOME%\bin;%PATH%
cd E:\编程技术\pki\测试自签名多级证书
E:
echo 1)生成自签名根证书testroot,不要重新生成根证书
keytool -genkeypair -alias testroot -deststoretype pkcs12 -keyalg RSA -keysize 2048 -sigalg SHA256withRSA -validity 3650 -keystore testroot.keystore -storepass abcde### -keypass abcde### -dname "CN=testroot, OU=testrootca, O=测试数据证书中心, L=太原, ST=山西省, C=CN"
echo 导出根证书testroot
keytool -exportcert -deststoretype pkcs12 -keystore testroot.keystore -storepass abcde### -alias testroot -file testrootca.cer
echo 2)查看生成的根证书库结果
keytool -list -keystore testroot.keystore -storepass abcde### –v
echo 3) 生成二级的自签名证书
keytool -genkeypair -keyalg RSA -keysize 2048 -sigalg SHA256withRSA -validity 3650 -alias test2.com -keystore test2.com.keystore -storepass abcde### -keypass abcde### -deststoretype pkcs12 -ext bc:ca:true,pathlen:3 -ext SAN=dns:test2.com,dns:www.test2.com,ip:192.168.0.103,ip:127.0.0.1 -dname "CN=www.test2.com, OU=testroot, O=xx科技公司, L=太原, ST=山西省, C=CN"
echo 4)查看生成的二级证书库结果
keytool -list -keystore test2.com.keystore -storepass abcde### –v
echo 生成二级证书签名申请文件
keytool -certreq -keyalg RSA -alias test2.com -deststoretype pkcs12 -ext bc:ca:true,pathlen:3 -ext SAN=dns:test2.com,dns:www.test2.com,ip:192.168.0.103,ip:127.0.0.1 -keystore test2.com.keystore -storepass abcde### -file test2.com.csr -v
echo 查看二级证书签名申请文件
keytool -printcertreq -file test2.com.csr
echo 4.去测试根证书认证中心认证
keytool -gencert -deststoretype pkcs12 -alias testroot -keystore testroot.keystore -storepass abcde### -ext bc:ca:true,pathlen:3 -ext SAN=dns:test2.com,dns:www.test2.com,ip:192.168.0.103,ip:127.0.0.1 -validity 3650 -infile test2.com.csr -outfile test2.com.cer
rem 必须导入签名用的根证书到二级证书库,否则会报错“java.lang.Exception: 无法从回复中建立链”
keytool -importcert -trustcacerts -deststoretype pkcs12 -alias testroot -keystore test2.com.keystore -storepass abcde### -file testrootca.cer
echo 5.导入签名认证后的证书到二级证书库
keytool -importcert -trustcacerts -deststoretype pkcs12 -alias test2.com -keystore test2.com.keystore -storepass abcde### -file test2.com.cer
echo 6.查看结果
cls
keytool -list -keystore test2.com.keystore -storepass abcde### –v
echo 7.安装根证书,只需安装根证书即可,以可以做在setup.exe安装文件
certmgr.Exe /c /add testrootca.cer /s root
或者通过certmgr.msc手工安装证书
证书存储区:
My 个人证书的X.509证书存储区。
AddressBook 其他用户的X.509证书存储区。
AuthRoot 第三方证书颁发机构(CA)的X.509证书存储区。
CertificateAuthority 中间证书颁发机构(CA)的X.509证书存储区。
Disallowed 吊销的证书的X.509证书存储区。
Root 受信任的根证书颁发机构(CA)的X.509证书存储区。
TrustedPeople 直接受信任的人和资源的X.509证书存储区。
TrustedPublisher 直接受信任的发行者的X.509证书存储区。
---------------------------------------------------
把test2.com.keystore拷贝到E:/apache-tomcat-9.0.35/conf/test2.com.keystore
copy test2.com.keystore E:\apache-tomcat-9.0.35\conf
修改tomcat配置文件
E:\apache-tomcat-9.0.35\conf\server.xml
<Connector port="8080" protocol="HTTP/1.1"
URIEncoding="utf-8"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="E:/apache-tomcat-9.0.35/conf/test2.com.keystore" keystorePass="abcde###"
/>
如要实现访问http自动跳转到https,则在conf/web.xml的最下面</web-app>前加上
<login-config>
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<security-constraint>
<web-resource-collection >
<web-resource-name >SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
检查安装结果:
运行: certmgr.msc
证书-当前用户->受信任的根证书颁发机构->证书->testroot
修改C:\Windows\System32\drivers\etc\hosts,增加2行:
127.0.0.1 www.test2.com
127.0.0.1 test2.com
启动tomcat
在chrome浏览器登录
访问 http://www.test2.com:8080 时会自动跳转到 https://www.test2.com:8443
https://www.test2.com:8443
-------------------------------------------
echo 测试三级证书
echo 3) 生成三级的自签名证书
keytool -genkeypair -keyalg RSA -keysize 2048 -sigalg SHA256withRSA -validity 3650 -alias test3.com -keystore test3.com.keystore -storepass abcde### -keypass abcde### -deststoretype pkcs12 -ext SAN=dns:test3.com,dns:www.test3.com,ip:192.168.0.103,ip:127.0.0.1 -dname "CN=www.test3.com, OU=testroot, O=xx科技公司, L=太原, ST=山西省, C=CN"
echo 4)查看生成的三级证书库结果
keytool -list -keystore test3.com.keystore -storepass abcde### –v
echo 生成三级证书签名申请文件
keytool -certreq -keyalg RSA -alias test3.com -deststoretype pkcs12 -ext SAN=dns:test3.com,dns:www.test3.com,ip:192.168.0.103,ip:127.0.0.1 -keystore test3.com.keystore -storepass abcde### -file test3.com.csr -v
echo 查看三级证书签名申请文件
keytool -printcertreq -file test3.com.csr
echo 4.去测试二级书认证中心认证
keytool -gencert -deststoretype pkcs12 -alias test2.com -keystore test2.com.keystore -storepass abcde### -ext SAN=dns:test3.com,dns:www.test3.com,ip:192.168.0.103,ip:127.0.0.1 -validity 3650 -infile test3.com.csr -outfile test3.com.cer
keytool -importcert -trustcacerts -deststoretype pkcs12 -alias testroot -keystore test3.com.keystore -storepass abcde### -file testrootca.cer
rem 必须导入签名用的二级证书到三级证书库,否则会报错“java.lang.Exception: 无法从回复中建立链”
keytool -importcert -trustcacerts -deststoretype pkcs12 -alias test2.com -keystore test3.com.keystore -storepass abcde### -file test2.com.cer
echo 5.导入签名认证后的证书到三级证书库
keytool -importcert -trustcacerts -deststoretype pkcs12 -alias test3.com -keystore test3.com.keystore -storepass abcde### -file test3.com.cer
echo 6.查看结果
cls
keytool -list -keystore test3.com.keystore -storepass abcde### –v
echo 不需要导入test2.com.cer证书
把test3.com.keystore拷贝到E:/apache-tomcat-9.0.35/conf/test3.com.keystore
copy test3.com.keystore E:\apache-tomcat-9.0.35\conf
修改tomcat配置文件
E:\apache-tomcat-9.0.35\conf\server.xml
<Connector port="9443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="E:/apache-tomcat-9.0.35/conf/test3.com.keystore" keystorePass="abcde###"
/>
检查安装结果:
修改C:\Windows\System32\drivers\etc\hosts,增加2行:
127.0.0.1 www.test3.com
127.0.0.1 test3.com
启动tomcat
在chrome浏览器登录
访问 http://www.test2.com:8080 时会自动跳转到 https://www.test2.com:8443
http://www.test2.com:8080 自动跳转到 https://www.test2.com:8443
http://www.test3.com:8080 自动跳转到 https://www.test3.com:8443 但证书无效
https://www.test2.com:8443
https://www.test3.com:9443
https://test2.com:8443
https://192.168.0.103:8443
https://127.0.0.1:8443
https://test3.com:9443
https://192.168.0.103:9443
https://127.0.0.1:9443
自签名多级证书亲测可用相关推荐
- SM2 生成公钥私钥 签名 加解密 亲测可用
引入pom依赖 <dependency><groupId>com.google.guava</groupId><artifactId>guava< ...
- 微信支付rootca.pem通用根证书文件,亲测可用
微信支付rootca.pem通用根证书文件,2018年5月后微信支付默认不提供. 我当初找了好久又花钱又费时才找的可以用的证书,亲测可用. 链接:https://download.csdn.net/d ...
- h5微信本地调试 vue_UniApp本地调试H5(谷歌chrome浏览器)跨域问题的解决方法,亲测可用...
UniApp本地调试H5跨域(谷歌chrome浏览器,UniApp内置浏览器不存在此问题)的推荐方案:欺骗浏览器,让浏览器觉得你没有跨域(其实还是跨域了,用的是代理) 客户器端解决方案(亲测可用): ...
- 每日起床前做这五个动作,可保障你终身不感冒——奥运福娃设计师韩美林老师亲测可用
1.醒来后第一件事不是起身,先在床上躺着伸懒腰→四肢拉直了→让经脉拉直了(来回拉三四次) 2.然后做下图的姿势,侧卧→抱膝→弯曲→膝盖顶住胸部→吐气,把所有体内的浊气吐出 3.然后坐起来,双手在脸上的 ...
- java正则 括号_java正则表达式获取大括号小括号内容并判断数字和小数亲测可用...
获取大括号小括号内容 项目开发用到了,暂做个简单记录 private static String regex = "\\{([^}]*)\\}";//匹配大括号 private s ...
- Android FFmpeg移植总攻略——获取视频帧数(亲测可用)
第一次尝试使用Android 移植FFmpeg算法,一路坎坷,最终做如下总结,适用于Android手机.Android开发板.亲测可用. 一.下载组件 在Android Studio中下载所需组件:C ...
- Android 手势返回上一界面 亲测可用
在现如今,Android使用越来越便捷,也对Android开发提出更高要求,便捷体现在开发的每一处. 这里介绍Android使用手势返回上一界面.亲测可用! 一.思考: 1. 监听可手势返回上一界面的 ...
- VC6.0连接数据库,并把大量数据从ACCess转移到SQL sever2008 的问题(亲测可用)
如果以下有不懂,可以加我微信交流xpj13098878561 VC6.0连接数据库,并把大量数据从ACCess转移到SQL sever2008 的问题(亲测可用) VC6.0下载连接https://p ...
- linux samba默认端口,Linux 指定端口挂载samba 亲测可用!
我在云主机开启了445,,46端口 通过tcptraceroute可以看到,运营商屏蔽了访问445 samba 端口 chunli@ubuntu ~$ tcptraceroute 47.88.159. ...
最新文章
- LINUX 上的 Shebang 符号(#!)
- 滴滴为啥值3600亿?看它的数据中台就知道了
- Linux服务器同步时间
- P4322-[JSOI2016]最佳团体【0/1分数规划,树形背包】
- 【笔记】jQuery源码(节点遍历)
- Java 10:局部变量类型推断
- HDFS Federation机制
- Acrobat DC安装方法
- Docker 基础 ( 二十 ) 部署Redis集群,问题记录
- python 异步IO编程
- Windows CE 5.0 五笔输入法
- 小型游戏《笑傲江湖之精忠报国》全过程_01
- JAVA笔试面试题集锦05
- 联想r480安全模式_thinkpad笔记本如何进入安全模式?
- [Ansible专栏]Ansible条件判断的介绍和使用
- python 死循环捕捉输入异常
- 当时我就哭了!中国首个火星探测器天问一号发射成功!
- 针对日语二级的学习方法
- 基于Google Earth Engine Explorer谷歌地球引擎GEE浏览界面实现遥感影像地物监督分类
- 哈佛学生是如何度过大学4年的
热门文章
- mos管的rc吸收电路计算_RC吸收计算应用.doc
- 逻辑运算符与位运算符的区别
- RPGMAKER游戏引擎基于JavaScript的插件制作(三)——重写方法预备知识教学
- PTA习题 7-4 定义抽象类Person、派生类Student和类Teacher
- DAU与GMV的差异,蛋鸡与肉鸡的区别
- 华为南研所提前批面试(2015年8月22日)
- java实时语音通话案例_java语音播报案例
- Hibernate中SessionFactory配置
- anz的swift code_澳洲Commonwealth bank是不是只有一个SWIFT CODE?
- 为什么毕业一年了工资还是只有7K