SSL证书问题javax.net.ssl.SSLHandshakeException:

时间:2013-09-27 09:56:19

标签: java

我正在尝试打开一个htttps网站。网址是ex。 https://x.xx.xx.xx/。我写了吹码。

String url =“https://x.xx.xx.xx/”;

网址obj =新网址(网址);

HttpURLConnection con =(HttpURLConnection)obj.openConnection();

//可选默认为GET con.setRequestMethod( “GET”);

//添加请求标头 con.setRequestProperty(“User-Agent”,USER_AGENT);

但它抛出异常“javax.net.ssl.SSLHandshakeException:java.security.cert.CertificateException:No subject alternative”。我是Java新手。 任何人都可以帮我解决上述问题。

已成功导入证书,仍然有例外,有人可以帮助我吗?

有impor

1 个答案:

答案 0 :(得分:0)

两种解决方案:  将服务器证书导入您的Java信任库或创建信任所有证书的自定义不安全TrustManager,请参阅Java and HTTPS url connection without downloading certificate示例。