Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailer extension should produce an ExtensionSslNativeSupportBuildItem #3221

Closed
dcdh opened this issue Jul 14, 2019 · 3 comments · Fixed by #3224 or #3377
Closed

Mailer extension should produce an ExtensionSslNativeSupportBuildItem #3221

dcdh opened this issue Jul 14, 2019 · 3 comments · Fixed by #3224 or #3377
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@dcdh
Copy link
Contributor

dcdh commented Jul 14, 2019

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):

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

@dcdh dcdh added the kind/bug Something isn't working label Jul 14, 2019
@machi1990
Copy link
Member

machi1990 commented Jul 14, 2019

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 machi1990 self-assigned this Jul 14, 2019
@dcdh
Copy link
Contributor Author

dcdh commented Jul 14, 2019

@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 gsmet reopened this Jul 30, 2019
@gsmet gsmet changed the title Unable to send email in native mode Mailer extension should produce an ExtensionSslNativeSupportBuildItem Jul 30, 2019
@gsmet gsmet added this to the 0.20.0 milestone Jul 30, 2019
@machi1990
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
3 participants