java https双向认证实现
来源:互联网 发布:服务器端口怎么关闭 编辑:程序博客网 时间:2024/04/30 18:37
1----server
keytool -genkeypair -keyalg RSA -keysize 2048 -sigalg SHA1withRSA -validity 3650 -alias www.cpsys.com -keystore cpsystem.keystore//创建库(直接给服务器用就可以了)
keytool -certreq -alias www.cpsys.com -keystore cpsystem.keystore -file lzwcom.csr -v //用于提交给ca (可以忽略)
keytool -exportcert -alias www.cpsys.com -keystore cpsystem.keystore -file lzwcom_certificate.cer -rfc // 服务端证书
2-----client
keytool -genkey -alias client -keyalg RSA -storetype PKCS12 -keystore client1.p12 //创建个人证书(可以直接导入浏览器,可以双击安装)
keytool -export -keystore client1.p12 -storetype PKCS12 -alias client -file client1key.cer //个人证书、客户端证书
3----server
keytool -import -file client1key.cer -keystore cpsystem.keystore -v //服务器添加信任个人证书(添加客户端证书)
4-----client(如果你用浏览器直接https访问,此步可以忽略,直接安装个人证书到浏览器就行了)
keytool -import -file lzwcom_certificate.cer -keystore "C:\Program Files\Java\jdk1.7.0_67\jre\lib\security\cacerts" -v //client服务器添加 server证书
//java cacerts 默认密码changeit
5-----------------tomcat server.xml配置
---双向认证
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="true" sslProtocol="TLS"
keystoreFile="e:\test\ca2\cpsystem.keystore"
keystorePass="123456"
truststoreFile="e:\test\ca2\cpsystem.keystore"
truststorePass="123456" />
---单向认证
<Connector port="8444" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="e:\test\ca2\cpsystem.keystore"
keystorePass="123456"
/>
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="true" sslProtocol="TLS"
keystoreFile="e:\test\ca2\cpsystem.keystore"
keystorePass="123456"
truststoreFile="e:\test\ca2\cpsystem.keystore"
truststorePass="123456" />
---单向认证
<Connector port="8444" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="e:\test\ca2\cpsystem.keystore"
keystorePass="123456"
/>
6-----------编写客户端https请求代码 或 浏览器直接https访问
测试中,如果编写https请求访问服务器,可能会出现 服务器证书与所访问主机名 不匹配的情况,此时修改host文件就行了
7--------
以后更新时,先删除原来的证书,然后导入新的证书
keytool -list -keystore cacerts
keytool -delete -alias akazam_email -keystore cacerts
keytool -import -alias akazam_email -file akazam_email.cer -keystore cacerts
自定义文件和密码路径,还没有验证:
Define the TrustStore using the JAVA_OPTS variable on the Stash Server:
You will have to do the following:
On Windows:
JAVA_OPTS = -Djavax.net.ssl.trustStore="%JAVA_HOME%\jre\lib\security\cacerts" -Djavax.net.ssl.trustStorePassword="changeit"
On Linux:
JAVA_OPTS = -Djavax.net.ssl.trustStore="$JAVA_HOME/jre/lib/security/cacerts" -Djavax.net.ssl.trustStorePassword="changeit"
(info) On my local instance trustStore password is changeit so I belive, if you didn´t changed it, your is changeit as well.
tomcat、junit运行时会从默认路径加载cacerts文件,如果main函数直接运行需要指定javax.net.ssl.trustStore文件路径,比如:
java -Djavax.net.ssl.trustStore=$JAVA_HOME/jre/lib/security/cacerts -jar XXX.jar
keytool -list -keystore cacerts
keytool -delete -alias akazam_email -keystore cacerts
keytool -import -alias akazam_email -file akazam_email.cer -keystore cacerts
自定义文件和密码路径,还没有验证:
Define the TrustStore using the JAVA_OPTS variable on the Stash Server:
You will have to do the following:
(info) On my local instance trustStore password is changeit so I belive, if you didn´t changed it, your is changeit as well.
tomcat、junit运行时会从默认路径加载cacerts文件,如果main函数直接运行需要指定javax.net.ssl.trustStore文件路径,比如:
java -Djavax.net.ssl.trustStore=$JAVA_HOME/jre/lib/security/cacerts -jar XXX.jar
1 0
- java https双向认证实现
- java实现https双向认证
- java中实现https双向认证
- CXF实现HTTPS双向认证
- Java nginx https 双向认证
- java 通过Httpclient模拟https Post 请求,实现双向认证
- php用curl实现https双向认证
- C#中实现https的双向认证
- nginx与ios实现https双向认证
- ASIHTTPRequest实现https双向认证请求
- ASIHTTPRequest实现https双向认证请求
- ASIHTTPRequest实现https双向认证请求
- ASIHTTPRequest实现https双向认证请求
- ASIHTTPRequest实现https双向认证请求
- ASIHTTPRequest实现https双向认证请求
- 基于HTTPS的双向认证实现
- Tomcat实现https双向认证功能
- Java keytool配置https双向认证
- 数组的概述,内存分配,两种数据类型的对比
- 第三个页面 移动端&PC端
- 379.Reorder array to construct the minimum number-将数组重新排序以构造最小值(中等题)
- echart2.0实现折线图转折点闪烁效果
- 解决Oracle 11g在用EXP导出时,空表不能导出的问题
- java https双向认证实现
- Mark!Android最佳的开源库集锦
- 5款常见原型工具,产品特色知多少?
- /*题目:将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。 */
- The type org.springframework.dao.support.DaoSupport cannot be resolved. It is indirectly referenced
- 最长上升子序列题目大合集
- 基于redis构建消息队列
- codevs 4175 洛谷 P1951 收费站(二分+spfa验证)
- java NIO详解(一)