You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Shing Hing Man <ma...@yahoo.com> on 2014/05/28 21:59:10 UTC

Problem with smtps when javax.net.ssl.trustStore is set

Hi,
  I am using Camel  2.12.1.

The following route sends email to my gmail account.

from("direct:a").to("smtps://smtp.gmail.com:465?username=admin@another.com&password=foo123&debugMode=true");


But when I added the following piece code before the above route,
 String userHome=System.getProperty("user.home");
   String keyStoreFile=userHome + "/keystore/selfSigned.jks";
      System.setProperty("javax.net.ssl.trustStore",keyStoreFile);

sending email no longer works. 


[                          main] DefaultCamelContext            INFO  Apache Camel 2.12.1 (CamelContext: camel-1) is starting
[                          main] ManagedManagementStrategy      INFO  JMX is enabled
[                          main] DefaultTypeConverter           INFO  Loaded 226 type converters
[                          main] DefaultCamelContext            INFO  StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
DEBUG: setDebug: JavaMail version 1.4.7
[                          main] DefaultCamelContext            INFO  Route: route1 started and consuming from: Endpoint[direct://a]
[                          main] DefaultCamelContext            INFO  Total 1 routes, of which 1 is started.
[                          main] DefaultCamelContext            INFO  Apache Camel 2.12.1 (CamelContext: camel-1) started in 0.393 seconds
DEBUG: setDebug: JavaMail version 1.4.7
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL true
[                          main] DefaultErrorHandler            ERROR Failed delivery for (MessageId: ID-gauss-site-38332-1401306585164-0-1 on ExchangeId: ID-gauss-site-38332-1401306585164-0-2). Exhausted after delivery attempt: 1 caught: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
  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


selfSigned.jks is derived from a self-signed certificated. 

I get the same error even if selfSigned.jks is replaced by a jks that is derived from a certificate signed by GoDaddy.


The above set up is in my test cases, so that I can send https messages to a local https server. 

What I need is to able to send https mesage and also send email using the above email route.

Thanks in advance for any assistance !
Shing

Re: Problem with smtps when javax.net.ssl.trustStore is set

Posted by Shing Hing Man <ma...@yahoo.com>.
After some goolging, I have found a solution to my problem, which has nothing to do with Camel. 

Basically, I need to add the Google mail ssl certificate to selfSigned.jks .
There is a  more detail explanation below : 


http://springinpractice.com/2012/04/29/fixing-pkix-path-building-issues-when-using-javamail-and-smtp



Shing 





On Wednesday, 28 May 2014, 20:59, Shing Hing Man <ma...@yahoo.com> wrote:
 


Hi,
  I am using Camel  2.12.1.

The following route sends email to my gmail account.

from("direct:a").to("smtps://smtp.gmail.com:465?username=admin@another.com&password=foo123&debugMode=true");


But when I added the following piece code before the above route,
 String userHome=System.getProperty("user.home");
   String keyStoreFile=userHome + "/keystore/selfSigned.jks";
      System.setProperty("javax.net.ssl.trustStore",keyStoreFile);

sending email no longer works. 


[                          main] DefaultCamelContext            INFO  Apache Camel 2.12.1 (CamelContext: camel-1) is starting
[                          main] ManagedManagementStrategy      INFO  JMX is enabled
[                          main] DefaultTypeConverter           INFO  Loaded 226 type converters
[                          main] DefaultCamelContext            INFO  StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
DEBUG: setDebug: JavaMail version 1.4.7
[                          main]
 DefaultCamelContext            INFO  Route: route1 started and consuming from: Endpoint[direct://a]
[                          main] DefaultCamelContext            INFO  Total 1 routes, of which 1 is started.
[                          main] DefaultCamelContext            INFO  Apache Camel 2.12.1 (CamelContext: camel-1) started in 0.393 seconds
DEBUG: setDebug: JavaMail version 1.4.7
DEBUG: getProvider() returning
 javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL true
[                          main] DefaultErrorHandler            ERROR Failed delivery for (MessageId: ID-gauss-site-38332-1401306585164-0-1 on ExchangeId: ID-gauss-site-38332-1401306585164-0-2). Exhausted after delivery attempt: 1 caught: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
  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


selfSigned.jks is derived from a self-signed certificated. 

I get the same error even if selfSigned.jks is replaced by a jks that is derived from a certificate signed by GoDaddy.


The above set up is in my test cases, so that I can send https messages to a local https server. 

What I need is to able to send https mesage and also send email using the above email route.

Thanks in advance for any assistance !
Shing