Certificate for <xx.xxx.xxx.xxx> doesn‘t match any of the subject alternative names: [xx.xxxx.xxxx.
1、 用HttpClient发送Https请求报SSLException: Certificate for <域名> doesn't match any of the subject alternative names问题的解决,报错,如下所示:
1 javax.net.ssl.SSLPeerUnverifiedException: Certificate for <xx.xxx.xxx.xxx> doesn't match any of the subject alternative names: [xx.xxxx.xxxx.com]2 at org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:507)3 at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:437)4 at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:384)5 at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)6 at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)7 at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)8 at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)9 at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) 10 at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) 11 at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) 12 at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) 13 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) 14 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
2、使用Apache HttpClient做https的Post请求,调用代码就报上面的错误。
可以参考链接:java - javax.net.ssl.SSLException: Certificate doesn't match any of the subject alternative names - Stack Overflow
代码参考,需要特别注意的是SSLContexts引入的httpcore-4.4.14.jar包,如下所示:
1 package com.xxx.main.httpclient;2 3 import org.apache.http.conn.ssl.NoopHostnameVerifier;4 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;5 import org.apache.http.conn.ssl.TrustSelfSignedStrategy;6 import org.apache.http.impl.client.CloseableHttpClient;7 import org.apache.http.impl.client.HttpClients;8 import org.apache.http.ssl.SSLContexts;9 10 public class HttpClientMain { 11 12 13 public static void testShared(String catalogId, String appKey, String secret) throws Exception { 14 CloseableHttpClient httpClient = null; 15 16 // 解决httpClient发送https错误的问题 17 SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory( 18 SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(), 19 NoopHostnameVerifier.INSTANCE); 20 httpClient = HttpClients.custom().setSSLSocketFactory(scsf).build(); 21 22 // ....... 23 24 } 25 26 27 }
Certificate for <xx.xxx.xxx.xxx> doesn‘t match any of the subject alternative names: [xx.xxxx.xxxx.相关推荐
- Certificate for <xxx.xxx.xxx.com> doesn‘t match any of the subject alternative names: [xxx..com]
问题和解决 我这里先描述问题和解决方案吧.很多同学不太关心发生的背景. 问题表象 Certificate for <xxx.xxx.xxx.com> doesn't match any o ...
- Certificate for doesn't match any of the subject alternative names: [.xxx.id, .yyy.id, mmm.id]
强烈推荐一个大神的人工智能的教程:http://www.captainbed.net/zhanghan [前言] 最近在调用第三方测试环境的时候日志中报Certificate for doesn't ...
- 用HttpClient发送HTTPS请求报SSLException: Certificate for <域名> doesn‘t match any of the subject alternative
目录 1:HttpClient 的https证书验证请求问题 2: post请求示例 3: get请求示例 1:HttpClient 的https证书验证请求问题 最近用http 推送,用apache ...
- Certificate doesn't match any of the subject alternative names问题的解决
用HttpClient发送HTTPS请求报SSLException: Certificate for <域名> doesn't match any of the subject alter ...
- Java笔记-解决WebServiceTemplate中No subject alternative names matching IP address xxx
主要的原因是证书有问题,就是程序的IP地址和证书的IP地址不匹配. 这里是客户端报错,使用的是spring-ws 对应的Maven如下: <dependency><groupId&g ...
- 用HttpClient发送HTTPS请求报SSLException: Certificate for <域名> doesn’t match any of the subject alternativ
用exchage获取Outlook数据服务是因为证书问题导致,现在需要去除证书验证就可以访问了. ExchangeService service = new ExchangeServiceWithHo ...
- iOS:error: exportArchive:No certificate for team ‘xxx‘ matching ‘‘xxx found
打包上 appstore 的时候,报错: error: exportArchive:No certificate for team 'xxx' matching ''xxx found 发现本地钥匙串 ...
- C++ windows已在xxx.exe中触发一个断点,其原因可能是堆被损坏,这说明xx.exe中或它所加载的任何DLL中有bug。
windows已在xxx.exe中触发一个断点,其原因可能是堆被损坏,这说明xx.exe中或它所加载的任何DLL中有bug. 原因也可能是用户在xx.exe具有焦点时按下了F12. 输出窗口可能提 ...
- ES6中import * as xxx from ‘xxx‘的作用
import * as xxx from 'xxx' 会将 "xxx" 中所有 export 导出的内容组合成一个对象返回(或import * as obj from 'xx' 这 ...
最新文章
- PaddleDetection 个人测评
- php单元测试断言方法
- 0基础学python看什么书-编程语言学python必看这三本书,少走一半弯路
- PHP登录状态判定的思路
- 发帖回帖功能 java_百度贴吧发贴回贴POST接口
- 如何在 Java 中正确使用 wait, notify 和 notifyAll?
- VS2008 Web Application和Web Site的区别[转]
- JSK-2 整除问题【入门】
- java——题型和考点大纲
- 四种常见的颜色模式及各自的特点?
- (收藏)让你从骨子里爱上英文
- AltiumDesigner PCB案牍(3)—— PADS工程文件导入AD
- sql server 替换字段中的部分字符,替换指定字符的方法
- android免root管理自动启动不了,真正免root的Autostarts(管理自启)详细使用教程...
- [思语]_一花一世界,一树一菩提
- UCK全球路演走进佛山,跨链技术将加速区块链商业应用
- 网页设计标记工具——马克鳗
- react实现汉堡_React动画切换(开关)按钮(汉堡菜单)组件
- 为什么说互联网的下半场,是中国年轻人的新机会?
- centos 服务自启动管理