1. Generate KeyStore
set SERVER_DN="CN=Server, OU=ec, O=ec, L=nanchang, S=jiangxi, C=CN"
set CLIENT_DN="CN=Client, OU=ec, O=ec, L=nanchang, S=jiangxi, C=CN"
set KS_PASS=-storepass PASSWORDHERE
set KEYINFO=-keyalg RSA
keytool -genkey -alias Server -dname %SERVER_DN% %KS_PASS% -keystore server.keystore %KEYINFO% -keypass strongit
keytool -export -alias Server -file test_axis.cer %KS_PASS% -keystore server.keystore
keytool -import -file test_axis.cer %KS_PASS% -keystore client.truststore -alias serverkey -noprompt
keytool -genkey -alias Client -dname %CLIENT_DN% %KS_PASS% -keystore client.keystore %KEYINFO% -keypass strongit
keytool -export -alias Client -file test_axis.cer %KS_PASS% -keystore client.keystore
keytool -import -file test_axis.cer %KS_PASS% -keystore server.truststore -alias clientkey -noprompt
2. Modify server.xml
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" keystoreFile="D:\test\server.keystore" keystorePass="PASSWORDHERE"
truststoreFile="D:\test\server.truststore" truststorePass="PASSWORDHERE" sslProtocol="TLS" />
3. add below code into your invoke code
System.setProperty("javax.net.ssl.keyStore",
"D:\\test\\client.keystore");
System.setProperty("javax.net.ssl.keyStorePassword", "PASSWORDHERE");
System.setProperty("javax.net.ssl.trustStore",
"D:\\test\\client.truststore");
System.setProperty("javax.net.ssl.trustStorePassword",
"PASSWORDHERE");
URL url = new URL("https://localhost:8443/TOMCAT6/services/GetName");
posted on 2011-05-17 21:39
Daniel 阅读(321)
评论(0) 编辑 收藏 所属分类:
WebService