Java SSLException:证书中的主机名与www.googleapis.com不匹配

时间:2011-09-26 12:15:27

标签: java ssl google-api google-custom-search

环境:Mac OS X Lion& Linux Debian squeeze / sid,JDK 1.7.0& JDK 1.6.0_27

错误

javax.net.ssl.SSLException: hostname in certificate didn't match: <www.googleapis.com/74.125.47.95> != <*.googleapis.com> OR <googleapis.com> OR <*.googleapis.com> .

我在上述所有OS / JDK组合中都收到此错误。

背景:我正在使用google-api-services-customsearch和google-api-service-shopping jar来向Google发送网络服务电话。我的电话一直工作到一天前。从昨天开始,代码已经开始抛出......

javax.net.ssl.SSLException: hostname in certificate didn't match: <www.googleapis.com/74.125.47.95> != <*.googleapis.com> OR <googleapis.com> OR <*.googleapis.com>
    at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:228)
    at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54)
.....
    at com.google.api.services.shopping.Shopping$Products$List.execute(Shopping.java:156)

我尝试使用the instructions here将证书导入cacerts密钥库,但这似乎无法解决问题。

2 个答案:

答案 0 :(得分:2)

对我来说,https://stackoverflow.com/a/3904473/419863中描述的解决方案对我这种错误起作用。

答案 1 :(得分:0)

AsyncHttpClient客户=新的AsyncHttpClient(true,80,443);