之前的httpclient是这样创建的
PoolingClientConnectionManager conMgr = new PoolingClientConnectionManager();
DefaultHttpClient httpclient = new DefaultHttpClient(conMgr);
改为:
SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(), NoopHostnameVerifier.INSTANCE);
CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(scsf).build();
发现以下错误时,解决方法同上
provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
网友评论