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

解决方法参考:https://stackoverflow.com/questions/39762760/javax-net-ssl-sslexception-certificate-doesnt-match-any-of-the-subject-alterna

上一篇下一篇

猜你喜欢

热点阅读