How to solve a problem of coexistence of Java mail ssl
This article mainly introduces how to solve the problem of the coexistence of Java mail ssl, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
Recently, I encountered a problem in doing java mail ssl: using JavaMail to receive mail failed after the system was running for a certain time.
The error message goes like this:
Javax.mail.MessagingException: Connect failed
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.pop3.POP3Store.protocolConnect (POP3Store.java:148)
At javax.mail.Service.connect (Service.java:275)
At javax.mail.Service.connect (Service.java:156)
At javax.mail.Service.connect (Service.java:105)
Or an error occurs on a mail server that does not enable SSL as follows:
Nested exception is:
Java.net.ConnectException: Connection refused
At com.sun.mail.pop3.POP3Store.protocolConnect (POP3Store.java:148)
Telnet to the mail server, there is no problem with the user name and password, it seems that there is only a program problem.
Properties props = System.getProperties () is used when creating MailSession; I found an error when printing this. I should not have used SSL verification, but the verification information should not appear, so now if you do not need SSL links to remove these attributes every time you link to POP3, there will be no problem.
Finally know who changed System.getProperties (); originally in the same Tomcat also runs another system, that system uses the mail server is using SSL verification to send and receive mail, and 30 minutes will receive mail, because the program is not rigorous enough, there are the above errors, improved procedures, the two systems can finally co-exist in a TOMCAT.
Thank you for reading this article carefully. I hope the article "how to solve a problem of Java mail ssl coexistence" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!