https 之间调用Certificate for
2021-12-06 本文已影响0人
go_2021
之前的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