【发布时间】:2013-11-25 10:54:52
【问题描述】:
我正在尝试向服务器发送请求,但它遇到了以下错误,因为我知道应该创建一个证书但不知道该怎么做。我找到了这个answer,但无法实现它。
java.security.cert.CertificateException: No subject alternative DNS name matching www.example.com found.
代码
URL url = new URL("https://www.example.com:1897/services/myservice");
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setDoOutput(true);
con.setDoInput(true);
OutputStream os = con.getOutputStream();
m.marshal(auth, os);
m.marshal(auth, System.out);
os.flush();
con.getResponseCode();
【问题讨论】:
标签: java ssl https webservice-client