HTTPS and self-signed certificate issue

前端 未结 3 1808
無奈伤痛
無奈伤痛 2020-12-08 18:14

I have to use HTTPS for sending POST requests to a server (using a self-signed certificate). This is how I do it:

HttpClient httpClient = getHttpClient();

f         


        
3条回答
  •  遥遥无期
    2020-12-08 18:31

    try this before performing the request

        SSLSocketFactory ssl =  (SSLSocketFactory)http.getConnectionManager().getSchemeRegistry().getScheme( "https" ).getSocketFactory(); 
        ssl.setHostnameVerifier( SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER );
    

提交回复
热议问题