我有一些代码可以发送电子邮件并从模板文件中读取内容。
在我使用https之前一切正常。在这种情况下,将引发异常:
javax.net.ssl.SSLHandshakeException:
java.security.cert.CertificateException: No subject alternative DNS name matching lonlinux01 found.
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) [jsse.jar:1.7.0_40]
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884) [jsse.jar:1.7.0_40]
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276) [jsse.jar:1.7.0_40]
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270) [jsse.jar:1.7.0_40]
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341) [jsse.jar:1.7.0_40]
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153) [jsse.jar:1.7.0_40]
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868) [jsse.jar:1.7.0_40]
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804) [jsse.jar:1.7.0_40]
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016) [jsse.jar:1.7.0_40]
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312) [jsse.jar:1.7.0_40]
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339) [jsse.jar:1.7.0_40]
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323) [jsse.jar:1.7.0_40]
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563) [rt.jar:1.7.0_40]
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) [rt.jar:1.7.0_40]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300) [rt.jar:1.7.0_40]
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) [rt.jar:1.7.0_40]
at com.cerillion.wsc.workers.EmailWorker.getEmailTemplateFile(EmailWorker.java:99) [classes:]
...
代码
url = new URL(templateurl);
urlConnection = url.openConnection();
urlConnection.setConnectTimeout(connectionTimeout);
urlConnection.setReadTimeout(connectionTimeout);
BufferedReader breader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
在urlconnection.getinputstream()上失败
应用程序的其余部分似乎在https上运行良好。
1条答案
按热度按时间zpgglvta1#
tls客户端在证书中找不到(完全限定的)服务器名称。
看起来你正在连接服务器
lonlinux01
但是给定的服务器证书既没有公共名称lonlinux01
也不是一个主题的替代名称。。。因此,请使用完全限定的服务器名称调整连接字符串(以与证书中的名称匹配),或要求服务器管理员调整其证书(以与完全限定的服务器名称匹配)