楼上白说了。现在计划又改了。不需要验证码!! 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协议下面提交!!!

解决方案 »

  1.   

    1。使用ie访问你要连结的url地址,这时你会看到弹出一个询问是否继续和服务器建立连接的对话框(安全警报)。选择“查看证书”->“详细信息”->“复制文件到”导出数字证书(例: server.cer或server.crt)。
    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这个类!
      

  2.   

    http://hi.baidu.com/raybb/blog/item/81e7f1dc7e184da1cd116697.html就是这个文章,大家帮我看看。
      

  3.   

    httpclient 这个东西真好用! 我也有用过~