0

I've been trying for weeks to get to configure rundeck to send emails using my gmail smtp settings on a Centos7 vm. I do have an ssl cert (that I purchased) configured for the server. Not sure if that has something to do with it. So far I have:

  • Converted the "/etc/rundeck/rundeck-config.properties" file to "/etc/rundeck/rundeck-config.groovy" file
  • Updates the "/etc/sysconfig/rundeckd" file with the following settings. "export RUNDECK_WITH_SSL=true export RDECK_CONFIG_FILE="/etc/rundeck/rundeck-config.groovy"
  • Edited my "/etc/rundeck/rundeck-config.groovy" with the following text.

loglevel.default="INFO"
rdeck.base="/var/lib/rundeck"
rss.enabled=false

grails.mail.default.from="user@gmail.com"

dataSource.dbCreate = "update"
dataSource.url = "jdbc:h2:file:/var/lib/rundeck/data/rundeckdb;MVCC=true;TRACE_LEVEL_FILE=4"

grails {
  mail {
        host = "smtp.gmail.com"
        username = "user@gmail.com"
        port = 465
        password = "password"
        props = ["mail.smtp.auth":"true",
                "mail.smtp.port":"465",
                "mail.smtp.starttls.enable":"true",
                "mail.smtp.socketFactory.port":"465",
                "mail.smtp.socketFactory.fallback":"false"]
  }
}
grails.serverURL="https://rundeck-server:4443"
rundeck.log4j.config.file = "/etc/rundeck/log4j.properties"

If I run it with port 465, I receive the following error.

2019-01-03 14:57:26.260 ERROR --- [eduler_Worker-1] rundeck.services.NotificationService     : Error sending notification email to user@gmail.com for Execution 231: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1

If I configure using port 587, I receive the following error in the "/var/log/rundeck/service.log"

2019-01-03 15:05:52.121 ERROR --- [eduler_Worker-1] rundeck.services.NotificationService     : Error sending notification email to user@gmail.com for Execution 233: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not convert socket to TLS;
  nested exception is:
 javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. Failed messages: javax.mail.MessagingException: Could not convert socket to TLS;
  nested exception is:
 javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Alternatively, I installed mailx and although theres an error in the logs, it successfully sends an email when I run the following "echo "Your message" | mail -v -s "Message Subject" user@gmail.com" command. The output is

Resolving host smtp.gmail.com . . . done.
Connecting to x.x.x.x:465 . . . connected.
Error in certificate: Peer's certificate issuer is not recognized.
Comparing DNS name: "smtp.gmail.com"
SSL parameters: cipher=AES-xxx-GCM, keysize=xxx, secretkeysize=xxx,
issuer=CN=Google Internet Authority G3,O=Google Trust Services,C=US
subject=CN=smtp.gmail.com,O=Google LLC,L=Mountain View,ST=California,C=US
220 smtp.gmail.com ESMTP b22sm9658588ios.45 - gsmtp
>>> EHLO rundeck-server
250-smtp.gmail.com at your service, [x.x.x.x]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
>>> AUTH LOGIN
334 xxxx
>>> xxxx==
334 xxxx
>>> xxxx==
235 2.7.0 Accepted
>>> MAIL FROM:<user@rundeck-server>
250 2.1.0 OK xx - gsmtp
>>> RCPT TO:<user@gmail.com>
250 2.1.5 OK xx - gsmtp
>>> DATA
354  Go ahead xx - gsmtp
>>> .
250 2.0.0 OK xx - gsmtp
>>> QUIT
221 2.0.0 closing connection xx - gsmtp

I added the following to the bottom of my "/etc/mail.rc" file

set smtp=smtps://smtp.gmail.com:465
set smtp-auth=login
set smtp-auth-user=USER.GMAIL.COM
set smtp-auth-password='password'
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/
druffin
  • 163
  • 2
  • 15
  • So the issue is with the SSL cert that I have configured for the rundeck server. I tried the email settings with a new rundeck server that doesnt have ssl cert configured and it works perfectly. – druffin Jan 04 '19 at 18:44

2 Answers2

0

Looks like you're using a self-signed certificate or non trusted certificate by google, check that:

Related links:

Java: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

http://web.archive.org/web/20080820101722/http://blogs.sun.com/andreas/entry/no_more_unable_to_find

https://news.ycombinator.com/item?id=4920088

http://code.naishe.in/2011/07/looks-like-article-no-more-unable-to.html

MegaDrive68k
  • 3,768
  • 2
  • 9
  • 51
0

I send emails from my gmail account with these settings in /etc/rundeck/rundeck-config.groovy

grails {
  mail {
        host = "smtp.gmail.com"
        username = "USER"
        port = 587
        password = "PASSWORD"
        props = ["mail.smtp.starttls.enable":"true","mail.smtp.auth":"true","mail.smtp.socketFactory.port":"587","mail.smtp.socketFactory.fallback":"false"]
  }
}