来年剃光头 2015-10-29 07:14
浏览 4302

使用Closeablehttpclient.execute,ubuntu下出现以下证书问题

错误log
javax.net.ssl.SSLException: Certificate for <> doesn't match any of the subject alternative names: []
at org.apache.http.conn.ssl.DefaultHostnameVerifier.matchDNSName(DefaultHostnameVerifier.java:158) ~[httpclient-4.5.jar:4.5]
at org.apache.http.conn.ssl.DefaultHostnameVerifier.verify(DefaultHostnameVerifier.java:109) ~[httpclient-4.5.jar:4.5]
at org.apache.http.conn.ssl.DefaultHostnameVerifier.verify(DefaultHostnameVerifier.java:87) ~[httpclient-4.5.jar:4.5]
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.verifyHostname(SSLConnectionSocketFactory.java:461) [httpclient-4.5.jar:4.5]
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:395) [httpclient-4.5.jar:4.5]
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) [httpclient-4.5.jar:4.5]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107) [httpclient-4.5.jar:4.5]
代码段为:
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, Consts.UTF_8);
httpPost.setEntity(entity);
CloseableHttpResponse resp=null;
try {
resp = httpClient.execute(httpPost);
HttpEntity respEntity = resp.getEntity();
String body = EntityUtils.toString(respEntity, charset);

在执行到 resp = httpClient.execute(httpPost);在ubuntu下开发就会抛出异常,而在windows下开发则没有此类错误,请教大神这是什么问题。
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
    • ¥15 怀疑手机被监控,请问怎么解决和防止
    • ¥15 Qt下使用tcp获取数据的详细操作
    • ¥15 idea右下角设置编码是灰色的
    • ¥15 全志H618ROM新增分区
    • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
    • ¥15 NAO机器人的录音程序保存问题
    • ¥15 C#读写EXCEL文件,不同编译
    • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
    • ¥15 扩散模型sd.webui使用时报错“Nonetype”