Reputation: 59
I am attempting to send an email via smtp to smtp.mailgun.org. I am not concerned about the java code that is attempting to send the email.
Environment:
Windows 10 Eclipse Photon Java 1.8.0_191 java package: com.sun.mail.javax.mail:1.6.2
I am trying to send through 587 using TLS. I don't have much experience creating or modifying keystores.
In the eclipse.ini
, I added the following two arguments after the -vmargs
-Djavax.net.ssl.trustStore="C:/Program Files/Java/jdk1.8.0_192/jre/lib/security/cacerts "
-Djavax.net.ssl.trustStorePassword="password"
I restarted Eclipse and am continuing to get the error below.
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:1652)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:534)
at javax.mail.Service.connect(Service.java:291)
at javax.mail.Service.connect(Service.java:172)
at com.mako.mg.manager.MakoMailGunSmtpManager.sendEmail(MakoMailGunSmtpManager.java:158)
at com.mako.mg.manager.MakoMailGunSmtpManager.main(MakoMailGunSmtpManager.java:180)
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
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:503)
at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:443)
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1647)
... 5 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
... 16 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
... 22 more
Is my Eclipse having a problem using the cacerts? or do I need to create a keystore from the cacerts?
I cannot find c:\users\<myuser>\.keystore
. I am configured to view hidden files and folders.
Thank you for your help with this issue.
Upvotes: 0
Views: 17313
Reputation: 59
I added -Djavax.net.debug=ssl and looked through the steps prior to the failure. I found that my anti-virus was getting in the way and causing the failure. Turned off the anti-virus for testing and the email was sent successfully.
Found on AVG's site a link with the following steps
open AVG Antivirus, click on Menu->Settings->Components->Email Scanner->Customize. On the next window under 'Main Settings', please disable "scan outbound email" and let us know if that resolves the issue.
Upvotes: 1