Using Apache httpclient for https

后端 未结 4 1767
轻奢々
轻奢々 2020-11-29 18:00

I have enabled https in tomcat and have a self-signed certificate for server auth. I have created an http client using Apache httpClient. I have set a trust manager loading

4条回答
  •  被撕碎了的回忆
    2020-11-29 18:56

    According to the documentation you need to specify the key store:

    Protocol authhttps = new Protocol("https",  
          new AuthSSLProtocolSocketFactory(
              new URL("file:my.keystore"), "mypassword",
              new URL("file:my.truststore"), "mypassword"), 443); 
    
     HttpClient client = new HttpClient();
     client.getHostConfiguration().setHost("localhost", 443, authhttps);
    

提交回复
热议问题