我正在尝试与其他网络服务进行通信。我用谷歌的高级休息客户端测试了它。网络服务工作得很好。问题在于我的代码:
String uri ="https://192.168.160.180:8443/RebateWebService/version";
URL url = new URL(uri);
HttpsURLConnection connection =(HttpsURLConnection) url.openConnection();
//String encoded = Base64.encode("6:4711");
// String basicAuth = "Basic " + new String(new Base64().encode(userCredentials.getBytes()));
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/xml");
connection.setRequestProperty("Authorization", "Basic Njo0NzEx");
String lol;
if (connection.getResponseCode() != 200) {
lol="erreur de connection";
} else {
InputStream xml = connection.getInputStream();
lol=xml.toString();
connection.disconnect();
}
以下是抛出的异常:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
答案 0 :(得分:0)
确保您的证书的“CN”字段是域名(例如stackoverflow.com),而不是IP。