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.
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:
application.properties to define the quarkus.mailer.password= corresponding to the api key used in sendgridbuild_native.sh to your local graalvm pathbuild_native.sh./target/quarkus-sample-email-app-1.0-SNAPSHOT-runnercurl 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):
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/Linuxjava -version: openjdk version "1.8.0_202"Additional context
(Add any other context about the problem here.)
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 Spoke too early, maybe it is not possible since quarkus.mailer.ssl is set to true?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.
Most helpful comment
Hey @dcdh, I looked at the configuration file and I think you are missing
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 whenSpoke too early, maybe it is not possible sincequarkus.mailer.sslis set to true?SslNativeConfigBuildItemis aSimpleBuildItem. We could perhaps document thatquarkus.ssl.nativeconfig option is required and has to be set to true whenquarkus.mailer.ssl=truein the mailer guide.