访问https禁用证书检查 java.security.cert.CertificateException

 

java.security.cert.CertificateException

javax.net.ssl.SSLPeerUnverifiedException

final RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(new SimpleClientHttpRequestFactory() {
@Override
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
if (connection instanceof HttpsURLConnection) {
((HttpsURLConnection) connection).setHostnameVerifier(PROMISCUOUS_VERIFIER);
}
super.prepareConnection(connection, httpMethod);
}
});//访问https禁用证书检查

 

posted @ 2018-11-29 10:34  己为  阅读(4862)  评论(0编辑  收藏  举报