Java SSLException: hostname in certificate didn

2019-04-08 16:45发布

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

Error:

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> .

I'm getting this error in all the above OS/JDK combinations.

Background: I am using google-api-services-customsearch and google-api-service-shopping jars to do webservice calls to Google. My calls were working correctly until a day ago. Since yesterday, the code has started to throw...

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)

I tried importing the cert into the cacerts keystore using the instructions here, but that does not seem to solve the problem.

2条回答
Summer. ? 凉城
2楼-- · 2019-04-08 17:24

For me the solution described in https://stackoverflow.com/a/3904473/419863 worked for me for this kind of error.

查看更多
forever°为你锁心
3楼-- · 2019-04-08 17:42

AsyncHttpClient client = new AsyncHttpClient(true,80,443);

查看更多
登录 后发表回答