美文网首页
https 之间调用Certificate for

https 之间调用Certificate for

作者: go_2021 | 来源:发表于2021-12-06 10:23 被阅读0次

之前的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

相关文章

网友评论

      本文标题:https 之间调用Certificate for

      本文链接:https://www.haomeiwen.com/subject/ilygxrtx.html