楼上白说了。现在计划又改了。不需要验证码!! Protocol authhttps = new Protocol("https",
new AuthSSLProtocolSocketFactory(//这个应该怎么写,他是 implements SecureProtocolSocketFactory 我不知道应该怎么实现,请高手指教
new URL("file:my.keystore"), "mypassword",
new URL("file:my.truststore"), "mypassword"), 8443);
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost("sh.12530", 8443, authhttps);
/*只能使用相对路径*/
GetMethod httpget = new GetMethod("/");
client.executeMethod(httpget); 现在只需要考虑,如何把一个url&username=123&pass=123这样以post提交,前题是在https协议下面提交!!!
new AuthSSLProtocolSocketFactory(//这个应该怎么写,他是 implements SecureProtocolSocketFactory 我不知道应该怎么实现,请高手指教
new URL("file:my.keystore"), "mypassword",
new URL("file:my.truststore"), "mypassword"), 8443);
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost("sh.12530", 8443, authhttps);
/*只能使用相对路径*/
GetMethod httpget = new GetMethod("/");
client.executeMethod(httpget); 现在只需要考虑,如何把一个url&username=123&pass=123这样以post提交,前题是在https协议下面提交!!!
2。使用导出的数字证书来创建你的keystore
keytool -import -alias "my server cert" -file server.cer -keystore my.truststore
keytool -genkey -v -alias "my client key" -validity 365 -keystore my.keystore
3。在引入AuthSSLProtocolSocketFactory.java,AuthSSLX509TrustManager.java和AuthSSLInitializationError后在你的代码里按下面的例子里来进行ssl连接
Protocol authhttps = new Protocol("https",
new AuthSSLProtocolSocketFactory(
new URL("file:my.keystore"), "mypassword",
new URL("file:my.truststore"), "mypassword"), 8443);
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost("sh.12530", 8443, authhttps);
/*只能使用相对路径*/
GetMethod httpget = new GetMethod("/");
client.executeMethod(httpget);这是别人的。但是我不知道应该怎么修改。我不懂怎么实现AuthSSLProtocolSocketFactory这个类!