HTTPS主机名错误:应为 。是什么原因造成的?

浏览:44日期:2024-02-21
如何解决HTTPS主机名错误:应为 。是什么原因造成的??

似乎domain.com的SSL证书已授予sub.domain.com。或者,更有可能的是,以前将domain.com重命名为sub.domain.com而不更新SSL证书。

解决方法

尝试使用https连接到服务器时,出现“ HTTPS主机名错误:”错误。我的网址看起来像这样

https://sub.domain.com/tamnode/webapps/app/servlet.

我使用以下代码进行连接

// Create a URLConnection object for a URL URL url = new URL(requestedURL); HttpURLConnection.setFollowRedirects(false); // connect connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestProperty('User-Agent',USER_AGENT); //$NON-NLS-1$ OutputStreamWriter wr = new OutputStreamWriter(connection .getOutputStream());

但是然后得到一个错误

IOException: HTTPS hostname wrong: should be <sub.domain.com>. at sun.net.www.protocol.https.HttpsClient.checkURLSpoofing ....

这是过去有效但不再有效的代码。系统体系结构已作了一些更改,但是在与负责人联系之前,我需要获取更多数据。

什么会导致此错误?我可以关闭URLSpoofing检查吗?

相关文章: