Could not convert socket to TLS on Apache Commons Mail

2k Views Asked by At

I have a problem connecting to a SMTP Server with Apache Commons Mail. I have tried everything but the only thing I can find online is for Java Mail. This is my error:

Caused by: 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

I have seen that you can fix the issue on Java Mail with props.put("mail.smtp.ssl.trust", "smtp.gmail.com"); for example, but I can't a equivalent command to use on Apache Commons.

1

There are 1 best solutions below

0
Bill Shannon On

If you're really connecting to Gmail, you shouldn't need that. The Gmail certificate will be trusted by the default trust store. If you've configured a non-default trust store, add the Gmail certificate to that trust store using the InstallCert program.