彻底解决unable to find valid certification path to requested target
javax.net.ssl.SSLPeerUnverifiedException: Host name '***' does not match the certificate subject provided by the peer (CN=localhost, OU=MH, O=MH, L=SZ, ST=GD, C=CN)
20220614解决方法:
SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
httpClient = HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier(new NoopHostnameVerifier()).build();