You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Stephan Siano (JIRA)" <ji...@apache.org> on 2017/03/22 11:12:41 UTC

[jira] [Created] (CAMEL-11047) STARTTLS broken with camel-mail

Stephan Siano created CAMEL-11047:
-------------------------------------

             Summary: STARTTLS broken with camel-mail
                 Key: CAMEL-11047
                 URL: https://issues.apache.org/jira/browse/CAMEL-11047
             Project: Camel
          Issue Type: Bug
          Components: camel-mail
    Affects Versions: 2.18.3, 2.17.6
            Reporter: Stephan Siano


A to URI like
{noformat}
smtp://xxx:25?mail.smtp.starttls.enable=true&sslContextParameters=#sslContextParameters
{noformat}

will create an exception when trying to connect to the SMTP server. The error message is

{noformat}
javax.mail.MessagingException: Could not connect to SMTP host: xxx, port: 25;
  nested exception is:
      javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2102)
      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:699)
      at javax.mail.Service.connect(Service.java:366)
      at org.apache.camel.component.mail.DefaultJavaMailSender.send(DefaultJavaMailSender.java:112)
      at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:63)
      at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
      at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:173)
      at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:341)
      at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:168)
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
      at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
      at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
      at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
      at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:1)
      at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
      at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
      at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:221)
      at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
      at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:110)
      at com.sap.esb.camel.mail.endpoint.configurator.mail.impl.MailRouteSendingTest.testSendMail(MailRouteSendingTest.java:36)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
      at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
      at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
      at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:671)
      at sun.security.ssl.InputRecord.read(InputRecord.java:504)
      at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934)
      at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
      at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
      at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
      at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:598)
      at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:372)
      at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:217)
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2066)
      ... 52 more
{noformat}

The problem is that the fix introduced with CAMEL-8163 makes matters worse. The SSLSocketConnectionFactory is used for the connection to the SMTP server, not for the socket upgrade to TLS.

The fix would be to set the properties mail.[protocol].ssl.socketFactory instead of mail.[protocol].socketFactory.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)