Trusting all certificates using HttpClient over HTTPS

后端 未结 21 2327
北恋
北恋 2020-11-21 04:50

Recently posted a question regarding the HttpClient over Https (found here). I\'ve made some headway, but I\'ve run into new issues. As with my last problem, I

21条回答
  •  星月不相逢
    2020-11-21 05:10

    Daniel's answer was good except I had to change this code...

        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));
    
        ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
    

    to this code...

        ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
        SchemeRegistry registry = ccm.getShemeRegistry()
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));
    

    to get it to work.

提交回复
热议问题