Using Apache httpclient for https

后端 未结 4 1766
轻奢々
轻奢々 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:40

    When I used Apache HTTP Client 4.3, I was using the Pooled or Basic Connection Managers to the HTTP Client. I noticed, from using java SSL debugging, that these classes loaded the cacerts trust store and not the one I had specified programmatically.

    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    BasicHttpClientConnectionManager cm = new BasicHttpClientConnectionManager();
    builder.setConnectionManager( cm );
    

    I wanted to use them but ended up removing them and creating an HTTP Client without them. Note that builder is an HttpClientBuilder.

    I confirmed when running my program with the Java SSL debug flags, and stopped in the debugger. I used -Djavax.net.debug=ssl as a VM argument. I stopped my code in the debugger and when either of the above *ClientConnectionManager were constructed, the cacerts file would be loaded.

提交回复
热议问题