Quantcast
Channel: SCN : Popular Discussions - SAP HANA Cloud Platform
Viewing all articles
Browse latest Browse all 2334

PKIX path building failed when trying to connect via SMTPS

$
0
0

Dear all,

I have a strange problem connecting to my mail relay server using smtps. I am currently using the following Destination definition for the connection:

#mail.password=<< Existing password removed on Export >>
#
#Wed Mar 18 13:11:32 UTC 2015
Type=MAIL
mail.description=send notification mails
mail.user=/*here's the user name*/
mail.smtp.ssl.enable=true
mail.transport.protocol=smtps
Name=outbound_mail
mail.smtps.host=smtp.strato.de
mail.smtps.port=465
mail.smtps.auth=true

This is the code I am using to connect to the server:

if (mailTransport == null) {    try {        InitialContext mailCtx = new InitialContext();        logger.debug("Looking up Context java:comp/env/mail/{}",                jndiMailName);        mailSession = (Session) mailCtx                .lookup("java:comp/env/mail/" + jndiMailName);        mailTransport = mailSession.getTransport();    } catch (NamingException | MessagingException e) {        logger.error(e.getMessage(), e);    }
}
...
mailTransport.connect();
//prepare the mimeMessage
mailTransport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());

I am pretty sure that this already worked out of the box. Somehow since some months it fails with the following Exception:

2015 03 18 13:30:00#+00#ERROR#xxx.XxxSyncJob##anonymous#QuartzSchedulerFactory_Worker-5#na#p14885408trial#xxx#web##Error sending mail!javax.mail.MessagingException: Could not connect to SMTP host: smtp.strato.de, port: 465    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1972)    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642)    at javax.mail.Service.connect(Service.java:317)    at javax.mail.Service.connect(Service.java:176)    at javax.mail.Service.connect(Service.java:125)    at xxx.XxxSyncJob.sendMails(XxxSyncJob.java:619)    at xxx.XxxSyncJob.executeInternal(XxxJob.java:204)    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
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(Alerts.java:192)    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1868)    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1338)    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:154)    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)    at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:998)    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1294)    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1321)    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1305)    at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:548)    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:352)    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:233)    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1938)    ... 9 common frames omitted
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(PKIXValidator.java:385)    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)    at sun.security.validator.Validator.validate(Validator.java:260)    at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1320)    ... 20 common frames omitted
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)    ... 26 common frames omitted

These are teh steps Itried to solve the problem until now:

  • Add "mail.smtps.ssl.trust" with the value * to the destination properties
  • Add the certificate of the server to the application (maybe it's the wrong place?):

 

Thanks in advance and kind regards

 

 

Tim


Viewing all articles
Browse latest Browse all 2334

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>