I am trying to send a request to a server but it runs into following error, as I know should create a certificate but not sure how to do it. I've found this answer but could not implement it.
java.security.cert.CertificateException: No subject alternative DNS name matching www.example.com found.
Code
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();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…