尝试使用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 .
at sun.net.www.protocol.https.HttpsClient.checkURLSpoofing
....
这是过去工作但不再是工作的代码。系统架构发生了一些变化,但在接近负责人之前,我需要获得更多的数据。
什么可能导致这个错误?我可以关闭URLSpoofing检查吗?