public static CloseableHttpClient acceptsUntrustedCertsHttpClient() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
HttpClientBuilder b = HttpClientBuilder.create(); // setup a Trust Strategy that allows all certificates.
//
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
return true;
}
}).build();
b.setSslcontext( sslContext); // don't check Hostnames, either.
// -- use SSLConnectionSocketFactory.getDefaultHostnameVerifier(), if you don't want to weaken
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; // here's the special part:
// -- need to create an SSL Socket Factory, to use our weakened "trust strategy";
// -- and create a Registry, to register it.
//
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslSocketFactory)
.build(); // now, we create connection-manager using our Registry.
// -- allows multi-threaded use
PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager( socketFactoryRegistry);
b.setConnectionManager( connMgr); // finally, build the HttpClient;
// -- done!
CloseableHttpClient client = b.build();
return client;
}

How to ignore SSL certificate errors in Apache HttpClient 4.4的更多相关文章

  1. How to Move SSL certificate from Apache to Tomcat

    https://www.sslsupportdesk.com/how-to-move-ssl-certificate-from-apache-to-tomcat/ Apache uses x509 p ...

  2. How To Set Up Apache with a Free Signed SSL Certificate on a VPS

    Prerequisites Before we get started, here are the web tools you need for this tutorial: Google Chrom ...

  3. How To Create a SSL Certificate on Apache for CentOS 6

    About Self-Signed Certificates 自签证书.一个SSL证书,是加密网站的信息,并创建更安全的链接的一种方式.附加地,证书可以给网站浏览者显示VPS的的身份证明信息.如果一个 ...

  4. SSL certificate problem unable to get local issuer certificate解决办法

    SSL certificate problem unable to get local issuer certificate 解决办法: 下载:ca-bundle.crt 将它放在自己的wamp或者x ...

  5. Failed to connect to VMware Lookup Service……SSL certificate verification failed

    今天登陆vsphere web-client时候,报错如下: Failed to connect to VMware Lookup Service https://vc-test.cebbank.co ...

  6. How to disable SSL certificate checking with Spring RestTemplate?(使用resttemplate访问https时禁用证书检查)

    How to disable SSL certificate checking with Spring RestTemplate?(使用resttemplate访问https时禁用证书检查) **** ...

  7. 使用Letsencrypt做SSL certificate

    为什么要使用Letsencrypt做SSL certificate? 最简单直接的原因是免费.但是免费存在是否靠谱的问题,尤其是对安全要求比较高的网站,需要考虑使用letsencrypt的安全性是否符 ...

  8. Configure custom SSL certificate for RDP on Windows Server 2012 in Remote Administration mode

    Q: So the release of Windows Server 2012 has removed a lot of the old Remote Desktop related configu ...

  9. (转)How to renew your Apple Push Notification Push SSL Certificate

    转自:https://blog.serverdensity.com/how-to-renew-your-apple-push-notification-push-ssl-certificate/ It ...

随机推荐

  1. tensorflow之分类学习

    写在前面的话 MNIST教程是tensorflow中文社区的第一课,例程即训练一个 手写数字识别 模型:http://www.tensorfly.cn/tfdoc/tutorials/mnist_be ...

  2. Spark Transformations介绍

    背景 本文介绍是基于Spark 1.3源码 如何创建RDD? RDD可以从普通数组创建出来,也可以从文件系统或者HDFS中的文件创建出来. 举例:从普通数组创建RDD,里面包含了1到9这9个数字,它们 ...

  3. CentOS yum 安装LAMP PHP5.4版本

    CentOS yum 安装LAMP PHP5.4版本 [日期:2015-06-04] 来源:Linux社区  作者:rogerzhanglijie [字体:大 中 小]     Linux系统版本:C ...

  4. JAVA字节流(读写文件)

    InputStream此抽象类是表示字节输入流的所有类的超类.需要定义 InputStream 的子类的应用程序必须始终提供返回下一个输入字节的方法. int available()返回此输入流方法的 ...

  5. TClientDataSet[5]: 读取数据

    本例用到: TClientDataSet.Fields[];          { 字段集合; 它比 FieldList 有更多功能, 如可获取嵌套字段 } TClientDataSet.FieldL ...

  6. 苹果手机连wifi跳不出来登录网页解决办法

    1.点开要连接wifi后面的小叹号“!”,打开“自动登录” 2.打开设置,关闭SAFARI的“阻止弹窗” 3.重新连接wifi

  7. BZOJ3622 已经没有什么好害怕的了(动态规划+容斥原理)

    显然可以转化为一个阶梯状01矩阵每行每列取一个使权值和为k的方案数.直接做不可做,考虑设f[i][j]为前i行权值和至少为j,即在其中固定了j行选1的方案数.设第i行从1~a[i]列都是1且a[i]+ ...

  8. 访问控制列表-细说ACL那些事儿(ACL应用篇)

    1.ACL应用范围 通过前两期的ACL理论学习,大家知道ACL并不能单独完成控制网络访问行为或者限制网络流量的效果,而是需要应用到具体的业务模块才能实现上述功能. 那么ACL到底可以应用在哪些业务中呢 ...

  9. html/css/js 学习笔记 - 牛客网试卷:前端工程师能力评估

    display属性 : block : CSS1 块对象的默认值.将对象强制作为块对象呈递,为对象之后添加新行   可以定义高度和宽度 none : CSS1 隐藏对象.与 visibility 属性 ...

  10. 【题解】AC自动机题解合集

    最近貌似大家都在搞字符串?很长一段时间都没有写博客了……还是补一补坑吧. 感觉AC自动机真的非常优美了,通过在trie树上建立fail指针可以轻松解决多模匹配的问题.实际上在AC自动机上的匹配可以看做 ...