Quarkus Gmail Setup

102 views Asked by At

Getting javax.net.ssl.SSLHandshakeException: Failed to create SSL connection while trying to setup quarkus for Mailing system.

I'm new to quarkus. I have been trying to setup a mail service using this as reference - https://quarkus.io/guides/mailer-reference#gmail-specific-configuration

I have configured my application.yml as

quarkus:
  mailer:
    auth-methods: DIGEST-MD5 CRAM-SHA256 CRAM-SHA1 CRAM-MD5 PLAIN LOGIN
    from: [email protected]
    host: smtp.gmail.com
    port: 465 # For ssl
    ssl: true
    username: "[email protected]"
    password: "generated password"
    mock: false

Bear in mind, I have 2FA enabled. I followed this article to enable generated passwords as well allowing smtp for gmail - https://mailmeteor.com/blog/gmail-smtp-settings

I was unable to send any mail at all. After reading stack overflow post - Quarkus - no error but no email (with gmail) I was able to proceed with one step further.

Now, in my final step, I found this additional issue with SSL -

javax.net.ssl.SSLHandshakeException: Failed to create SSL connection

I did try with TLS too by changing quarkus.mailer.port to 587 and removing quarkus.mailer.ssl. But then I find this error - javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Can someone explain me why I'm getting the issue? And what could be the possible fixes to this.

Edit: I am quite inexperienced with ssl. So apologies if it sounds stupid. I did generate a pem file in resources using command openssl s_client -starttls smtp -connect smtp.gmail.com:587 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > google-smtp-ca.pem

The command is stuck with log as below and an empty file google.smtp-ca.pem.

depth=2 C = US, O = Google Trust Services LLC, CN = GTS Root R1
verify return:1
depth=1 C = US, O = Google Trust Services LLC, CN = GTS CA 1C3
verify return:1
depth=0 CN = smtp.gmail.com
verify return:1
250 SMTPUTF8

additional application.yml config I have configured

quarkus:
  ssl:
    truststore:
      file: google-smtp-ca.pem

I am using windows 11.

0

There are 0 answers