CloseableHttpClient忽略https证书认证
程序员文章站
2022-03-04 18:24:52
...
public static CloseableHttpClient getHttpsClient() {
CloseableHttpClient httpClient; if (ignoreSSL) {//ignoreSSL为true时,绕过证书 SSLContext sslContext = null; try { sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { return true; } }).build(); } catch (NoSuchAlgorithmException e) { e.getStackTrace(); } catch (KeyManagementException e) { e.getStackTrace(); } catch (KeyStoreException e) { e.getStackTrace(); } httpClient = HttpClients.custom().setSSLContext(sslContext). setSSLHostnameVerifier(new NoopHostnameVerifier()).build(); } else { httpClient = HttpClients.createDefault(); } return httpClient; }
上一篇: Spring5 WebClient忽略https证书认证
下一篇: Bootstrap 项目博览会
推荐阅读
-
.net core signalR 忽略https 证书
-
PHP Curl https跳过ssl证书认证报错记录及解决
-
【SSL证书行业】HTTPS认证支撑网络安全的防护门!
-
httpclient 忽略https,信任所有证书
-
HTTPS认证二: openssl生成证书及签名
-
探究公钥、私钥、对称加密、非对称加密、hash加密、数字签名、数字证书、CA认证、https它们究竟是什么,它们分别解决了通信过程的哪些问题。
-
创建忽略证书验证的CloseableHttpClient
-
httpclient访问需要客户端认证数字证书的https接口的处理方法
-
Spring5 WebClient忽略https证书认证
-
RestTemplate忽略https证书认证