我已经尝试了数周的时间来配置rundeck以使用Centos7虚拟机上的gmail smtp设置发送电子邮件。我确实为服务器配置了ssl证书(已购买)。不确定是否与此有关。到目前为止,我有:


将“ /etc/rundeck/rundeck-config.properties”文件转换为
“ /etc/rundeck/rundeck-config.groovy”文件
使用以下设置更新“ / etc / sysconfig / rundeckd”文件。 “导出RUNDECK_WITH_SSL = true
导出RDECK_CONFIG_FILE =“ / etc / rundeck / rundeck-config.groovy”
用以下文本编辑了我的“ /etc/rundeck/rundeck-config.groovy”。




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

grails.mail.default.from="[email protected]"

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 = "[email protected]"
        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"





如果使用端口465运行它,则会收到以下错误。



2019-01-03 14:57:26.260 ERROR --- [eduler_Worker-1] rundeck.services.NotificationService     : Error sending notification email to [email protected] 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





如果使用端口587进行配置,则会在“ /var/log/rundeck/service.log”中收到以下错误



2019-01-03 15:05:52.121 ERROR --- [eduler_Worker-1] rundeck.services.NotificationService     : Error sending notification email to [email protected] 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





另外,我安装了mailx,尽管日志中有错误,但是当我运行以下“ echo”“您的消息” | mail -v -s“消息主题” [email protected]”命令时,它成功发送了一封电子邮件。输出是



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:<[email protected]>
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





我在“ /etc/mail.rc”文件的底部添加了以下内容



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/

最佳答案

看来您使用的是Google的自签名证书或不受信任的证书,请检查以下内容:

相关链接:

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

关于ssl - Rundeck Gmail SMTP设置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54031138/

10-13 04:20