SMTP 메일을 사용하여 이메일을 보내고 있습니다. 아래에 주어진 smtp 설정 :ssl이없는 Java 메일 - PKIX 경로 구축 실패 :
Properties props = new Properties();
Object put = props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.user", smtpUser);
props.put("mail.smtp.auth", true);
props.put("mail.debug", mailDebug);
props.put("mail.smtp.port", port);
smtp 자격 증명은 위의 세부 사항으로 내 smtpHost에 telnetting하여 확인되었습니다. 그러나 자바 메일에서 위의 설정을 사용할 때 다음 예외가 발생합니다. 그것은 다시 동일한 인증 실패 예외를 생성
props.put("mail.smtp.starttls.enable", false);
: 나는 줄을 추가
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
DEBUG SMTP: Found extension "SIZE", arg "52428800"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "HELP", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN failed
Nov 29, 2012 11:54:40 AM com.Test main
SEVERE: null
javax.mail.AuthenticationFailedException: 535 Incorrect authentication data
. 두 번째 예외에 관한 다양한 포럼 스레드를 거쳐
220 TLS go ahead
Nov 28, 2012 5:32:36 PM com.Test main
SEVERE: null
javax.mail.MessagingException: Could not convert socket to TLS;
nested exception is:
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
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1918)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:652)
at javax.mail.Service.connect(Service.java:317)
:
나는 mail.smtp.starttls.enable 사실 에가, 인증이 성공 설정하면, 그러나 나는 다음과 같은 예외가 InstallCert 프로그램을 실행하여 서버의 자체 서명 된 인증서를 가져 왔습니다. InstallCert 다음과 같은 예외가 발생합니다 : 내 서버가 SSL이없는 것처럼
Opening connection to mydomain.com.au:443...
Starting SSL handshake...
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:542)
at sun.security.ssl.InputRecord.read(InputRecord.java:374)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:850)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1190)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1217)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1201)
at InstallCert.main(InstallCert.java:100)
Could not obtain server certificate chain
그래서, 보이는,하지만 STARTTLS를 사용할 수 있습니다. STARTTLS를 사용하여 메일을 보내는 올바른 매개 변수는 SSL이없는 서버에 무엇입니까?
나는 그 일을하려고 않은 경우. FAQ에 설명 된대로 InstallCert를 사용했는데 "javax.net.ssl.SSLException : Unrecognized SSL message, plaintext connection?"예외가 발생했습니다. 내 서버가 SSL을 전혀 사용하지 않는 것 같습니다. – janenz00
InstallCert 예외도 함께 내 질문을 편집했습니다. – janenz00
InstallCert의 문제점은 SSL 연결을 시작할 수있는 경우에만 작동한다는 것입니다. 서버가 SSL (TLS) 연결로 변환되는 일반 텍스트 연결 만 지원하는 경우 InstalCert는 도움이되지 않습니다. [MailSSLSocketFactory] (http://javamail.kenai.com/nonav/javadocs/com/sun/mail/util/MailSSLSocketFactory.html) 클래스를 보면 자체 서명 된 클래스를 더 쉽게 처리 할 수 있습니다. 그렇지 않으면 검증되지 않는 인증서. –