我正在尝试使用 HTTPClient / URLConnection 连接到 REST Web 服务。它是一个简单的代码,在 jdk 1.7 中运行良好,但在使用 jdk1.6 时会引发 SSLHandshake 异常
IO Exception: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching your.domain.name.com found.
...
Caused by: java.security.cert.CertificateException: No subject alternative DNS name matching your.domain.name.com found.
此外,代码非常基本
URL url = new URL("https://your.domain.name.com/services/");
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestProperty("Authorization", "Basic " + encodedCredenials);
urlConnection.setRequestProperty("Content-Type", "application/vnd.mtdomain.gold+json");
InputStream is = urlConnection.getInputStream();
这是 jdk 1.6 和 1.7 之间的已知问题吗?我们怎样才能解决这个问题?我不太熟悉 SSL 相关问题。