How to set camel mail component to use TLS 1.3

164 Views Asked by At

When trying to send mails using camel I get the following error:

Stacktrace: javax.mail.MessagingException: Could not convert socket to TLS;
  nested exception is:
        javax.net.ssl.SSLHandshakeException: Received fatal alert: protocol_version

The route I'm testing mail on:

from("direct:sendTestMail")
            .routeId("mail_test")
            .setHeader("subject", simple("test mail"))
            .to("smtp://xxxxx?"
                    + "port=587&"
                    + "mail.smtp.starttls.enable=true&"
                    + "username=xxxx&"
                    + "password=xxxx&"
                    + "from=xxxx&"
                    + "[email protected]&" 
                    + "[email protected]")
            .log("Mail sent.");

I guess that means that I should use TLS 1.3 instead of 1.2.

I can't seem to find a way to change protocol versions as the documentation seems a bit obscure on that point and the link that should be useful:

https://camel.apache.org/components/3.7.x/http-component.html#_setting_up_ssl_for_http_client

is currently broken.

I know that in newer versions of camel TLS 1.3 is the default version, but is it possible to set it in camel version 2.13.2?

1

There are 1 best solutions below

0
aratata On

In the end, all that was needed was one more line in my route:

"mail.smtp.ssl.protocols=TLSv1.3&"

so the config that worked was:

from("direct:sendTestMail")
            .routeId("mail_test")
            .setHeader("subject", simple("test mail"))
            .to("smtp://xxxxx?"
                    + "port=587&"
                    + "mail.smtp.ssl.protocols=TLSv1.3&"
                    + "mail.smtp.starttls.enable=true&"
                    + "username=xxxx&"
                    + "password=xxxx&"
                    + "from=xxxx&"
                    + "[email protected]&" 
                    + "[email protected]")
            .log("Mail sent.");