Quarkus: Mailer extension should produce an ExtensionSslNativeSupportBuildItem

Created on 14 Jul 2019  路  3Comments  路  Source: quarkusio/quarkus

Describe the bug

In native mode sending an email throw an exception and email is not sent.

Expected behavior
curl http://localhost:8080/simple should send a mail.

Actual behavior

An exception is thrown.

2019-07-14 18:31:24,598 INFO [io.quarkus] (main) Quarkus 0.19.1 started in 0.016s. Listening on: http://[::]:8080
2019-07-14 18:31:24,598 INFO [io.quarkus] (main) Installed features: [cdi, mailer, resteasy, vertx]
2019-07-14 18:31:28,720 SEVERE [io.ver.cor.imp.ContextImpl] (vert.x-eventloop-thread-0) Unhandled exception: io.vertx.core.VertxException: javax.net.ssl.SSLException: failed to initialize the client-side SSL context
at io.vertx.core.net.impl.SSLHelper.createContext(SSLHelper.java:318)
at io.vertx.core.net.impl.SSLHelper.getContext(SSLHelper.java:493)
at io.vertx.core.net.impl.SSLHelper.validate(SSLHelper.java:518)
at io.vertx.core.net.impl.NetClientImpl.doConnect(NetClientImpl.java:176)
at io.vertx.core.net.impl.NetClientImpl.doConnect(NetClientImpl.java:168)
at io.vertx.core.net.impl.NetClientImpl.connect(NetClientImpl.java:116)
at io.vertx.core.net.impl.NetClientImpl.connect(NetClientImpl.java:110)
at io.vertx.ext.mail.impl.SMTPConnection.openConnection(SMTPConnection.java:179)
at io.vertx.ext.mail.impl.SMTPStarter.start(SMTPStarter.java:49)
at io.vertx.ext.mail.impl.SMTPConnectionPool.createConnection(SMTPConnectionPool.java:240)
at io.vertx.ext.mail.impl.SMTPConnectionPool.createNewConnection(SMTPConnectionPool.java:224)
at io.vertx.ext.mail.impl.SMTPConnectionPool.getConnection0(SMTPConnectionPool.java:147)
at io.vertx.ext.mail.impl.SMTPConnectionPool.getConnection(SMTPConnectionPool.java:77)
at io.vertx.ext.mail.impl.MailClientImpl.getConnection(MailClientImpl.java:101)
at io.vertx.ext.mail.impl.MailClientImpl.lambda$sendMail$1(MailClientImpl.java:85)
at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:284)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320)
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:495)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:473)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
Caused by: javax.net.ssl.SSLException: failed to initialize the client-side SSL context
at io.netty.handler.ssl.JdkSslClientContext.newSSLContext(JdkSslClientContext.java:305)
at io.netty.handler.ssl.JdkSslClientContext.(JdkSslClientContext.java:270)
at io.netty.handler.ssl.SslContext.newClientContextInternal(SslContext.java:168)
at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:452)
at io.vertx.core.net.impl.SSLHelper.createContext(SSLHelper.java:309)
... 25 more
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: TLS, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$TLSContext)
at java.security.Provider$Service.newInstance(Provider.java:1621)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
at javax.net.ssl.SSLContext.getInstance(SSLContext.java:156)
at io.netty.handler.ssl.JdkSslClientContext.newSSLContext(JdkSslClientContext.java:287)
... 29 more
Caused by: java.lang.NoSuchMethodException: sun.security.ssl.SSLContextImpl$TLSContext.
at java.lang.Class.getConstructor0(DynamicHub.java:3082)
at java.lang.Class.getConstructor(DynamicHub.java:1825)
at java.security.Provider$Service.newInstance(Provider.java:1594)
... 33 more

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/dcdh/quarkus-sample-email-app.git
  2. update application.properties to define the quarkus.mailer.password= corresponding to the api key used in sendgrid
  3. update graalvm path in build_native.sh to your local graalvm path
  4. run build_native.sh
  5. start the application by using ./target/quarkus-sample-email-app-1.0-SNAPSHOT-runner
  6. use curl to call the endpoint sending the email curl http://localhost:8080/simple

Configuration

# Add your application.properties here, if applicable.
quarkus.mailer.password=**sendgrid api smtp key** 

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver: Linux arch-anywhere 5.1.6-arch1-1-ARCH #1 SMP PREEMPT Fri May 31 15:17:53 UTC 2019 x86_64 GNU/Linux
  • Output of java -version: openjdk version "1.8.0_202"
  • GraalVM version (if different from Java): graalvm-ce-19.0.2
  • Quarkus version or git rev: 0.19.1

Additional context
(Add any other context about the problem here.)

kinbug

Most helpful comment

Hey @dcdh, I looked at the configuration file and I think you are missing

quarkus.ssl.native=true

can you try adding the configuration option. For more info on how to set SSL in native images see our guide: https://quarkus.io/guides/native-and-ssl-guide

@gsmet @cescoffier should we activate activate ssl for native images when quarkus.mailer.ssl is set to true? Spoke too early, maybe it is not possible since SslNativeConfigBuildItem is a SimpleBuildItem. We could perhaps document that quarkus.ssl.native config option is required and has to be set to true when quarkus.mailer.ssl=true in the mailer guide.

All 3 comments

Hey @dcdh, I looked at the configuration file and I think you are missing

quarkus.ssl.native=true

can you try adding the configuration option. For more info on how to set SSL in native images see our guide: https://quarkus.io/guides/native-and-ssl-guide

@gsmet @cescoffier should we activate activate ssl for native images when quarkus.mailer.ssl is set to true? Spoke too early, maybe it is not possible since SslNativeConfigBuildItem is a SimpleBuildItem. We could perhaps document that quarkus.ssl.native config option is required and has to be set to true when quarkus.mailer.ssl=true in the mailer guide.

@machi1990 I confirm, adding quarkus.ssl.native=true in application.properties fix the problem.

Thanks a lot for your help.

Document this behavior into https://quarkus.io/guides/sending-emails may be a great help.

@gsmet I'll like to finish this work :-). Let me prepare something.

Was this page helpful?
0 / 5 - 0 ratings