Ignore self-signed certificates in Apache HTTPClient 4.5

后端 未结 4 845
深忆病人
深忆病人 2021-01-02 02:44

I am trying to accept all certificates, and/or accept self-signed certificates using Apache HTTPClient version 4.5 (tutorial link here)

4条回答
  •  Happy的楠姐
    2021-01-02 02:56

    One of the above approaches should work in case of self-signed certificates, but the weird thing is you are getting same exception in all the approaches.

    I feel during SSL session establishment or handshaking protocol is not being accepted either by client or by server.

    The best solution here is to debug the application.

    In case of tomcat, add -Djavax.net.debug=all in setenv.sh or setenv.bat files and then restart the server.

    Or you can follow this tutorial.

    The OP just needed to change the port when connecting to SSL:

    //For HTTPS
    HttpHost httpstarget = new HttpHost("mysite.com", 443, "https");
    
    //For HTTP
    HttpHost httptarget = new HttpHost("mysite.com", 80, "http");
    

提交回复
热议问题