我想從我製作的java程序中通過https連接到測試服務器。我不想驗證證書中的任何內容,我怎樣才能做到這一點?java https沒有驗證證書
我使用:
HttpURLConnection connection = (HttpURLConnection) (new URL(server).openConnection());
connection.setDoOutput (true);
connection.setDoInput (true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
OutputStream out = connection.getOutputStream();
OutputStreamWriter wout = new OutputStreamWriter(out, "UTF-8");
wout.write(xml);
wout.flush();
out .close();
//READ RESPONSE.
InputStream in = connection.getInputStream();
但是,當我執行,我得到:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
歡迎堆棧溢出錯誤,請[乘觀光(https://stackoverflow.com/tour) ,請確保你閱讀了[我如何寫出一個好的答案?](https://stackoverflow.com/help/how-to-answer)並更新了答案並提供了更多信息。 – lordrhodos