내 vps를 통해 이메일을 테스트하고 전송할 때 문제가 발생했습니다. SMTPS를 통한 안전한 메일. 전자 메일이 성공적으로 전송되면서 SMTP 및 POP3 기능이 작동합니다. SMTPS는 그렇지 않습니다.JavaMail이 vps를 통해 보안 이메일을 보내려면 SSLHandshake Exception, PKIX 경로 생성에 실패했습니다. - 메일을 보낼 수 없음
간단한 테스트 (JSP) 페이지를 설정하여 이메일을 보내주십시오. 코드는 아래에 제공됩니다.
내 vps에서는 보안 smtp 설정 지침을 따라야했습니다.
jsp 테스트 페이지를 실행 한 후 tomcat 로그 파일에서 다음 예외가 발생합니다.
INFO | jvm 1 | 2011/01/06 12:29:11 | DEBUG: setDebug: JavaMail version 1.4.1
INFO | jvm 1 | 2011/01/06 12:29:11 | DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
INFO | jvm 1 | 2011/01/06 12:29:11 | DEBUG SMTP: useEhlo true, useAuth true
INFO | jvm 1 | 2011/01/06 12:29:11 | DEBUG SMTP: trying to connect to host "mydomainname.com", port 465, isSSL true
INFO | jvm 1 | 2011/01/06 12:29:12 | DEBUG SMTP: exception reading response: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | javax.mail.MessagingException: Exception reading response;
INFO | jvm 1 | 2011/01/06 12:29:12 | nested exception is:
INFO | jvm 1 | 2011/01/06 12:29:12 | javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1611)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
INFO | jvm 1 | 2011/01/06 12:29:12 | at javax.mail.Service.connect(Service.java:288)
INFO | jvm 1 | 2011/01/06 12:29:12 | at javax.mail.Service.connect(Service.java:169)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jsp.SendEmailViaEappsVPS_005fSMTPS_jsp._jspService(SendEmailViaEappsVPS_005fSMTPS_jsp.java:112)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
INFO | jvm 1 | 2011/01/06 12:29:12 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
INFO | jvm 1 | 2011/01/06 12:29:12 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:774)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:896)
INFO | jvm 1 | 2011/01/06 12:29:12 | at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
INFO | jvm 1 | 2011/01/06 12:29:12 | at java.lang.Thread.run(Thread.java:595)
INFO | jvm 1 | 2011/01/06 12:29:12 | Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1584)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:848)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:877)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1089)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:737)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
INFO | jvm 1 | 2011/01/06 12:29:12 | at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
INFO | jvm 1 | 2011/01/06 12:29:12 | at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:88)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1589)
INFO | jvm 1 | 2011/01/06 12:29:12 | ... 26 more
INFO | jvm 1 | 2011/01/06 12:29:12 | Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.validator.Validator.validate(Validator.java:203)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:172)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320)
INFO | jvm 1 | 2011/01/06 12:29:12 | at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:841)
INFO | jvm 1 | 2011/01/06 12:29:12 | ... 38 more
INFO | jvm 1 | 2011/01/06 12:29:12 | Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:236)
INFO | jvm 1 | 2011/01/06 12:29:12 | at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:194)
INFO | jvm 1 | 2011/01/06 12:29:12 | at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:216)
INFO | jvm 1 | 2011/01/06 12:29:12 | ... 43 more
이것은 무엇을 의미합니까? 이전에 이런 유형의 예외를 본 사람이 있습니까? 이 문제를 해결하기 위해 어떤 단계를 밟아야합니까?
'안전한'이메일을 보내는 것이 필요하다고 생각하십니까? 아니면 그냥 smtps가 아닌 smtp를 사용할 수 있습니까? 괜찮습니까? – katura
이상적인 경우, 중간자 공격을 피하려면 SMTPS를 사용해야합니다. http://en.wikipedia.org/wiki/Man-in-the-middle_attack하지만 회사 정책에 따라 다릅니다. – Nishant
누구나이 링크가 가리키는 곳을 아십니까? 지금은 404입니다. ( – GreenKiwi