【发布时间】:2014-05-06 16:03:11
【问题描述】:
在生产服务器中发送电子邮件时,我遇到了 Open SSL 证书错误的问题。在开发模式下一切正常。下面是我在生产模式下的配置代码。
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => "plain",
:enable_starttls_auto => true,
:user_name => 'xxxxxxx',
:password => 'xxxxx',
:openssl_verify_mode => 'none'
}
我已经在previous post 中查看了解决方案,但是,这并没有解决我的问题。
有人可以帮忙解决这个问题吗?
【问题讨论】:
-
openssl_verify_mode => 'none'应该可以工作。确保它没有被某处覆盖。可悲的是,关闭主机名匹配是邮件中最好的方法,因为另一种选择是不加密。机会加密总比不加密好。首次使用信任 (TOFU) 等安全多样化策略会有所帮助,但这些系统很少实施。 -
感谢您的评论。我实际上也尝试通过输入 :enable_starttls_auto => false 来禁用加密,但仍然出现相同的错误。
-
不,你想要
enable_starttls_auto => true。这为您提供了机会加密。问题似乎出在主机名验证中,这似乎很奇怪,因为 Google 证书格式正确(不像托管公司那样没有适当注意细节)。您的问题出在其他地方。 -
证书中有哪些主机名?有拦截代理吗? Ruby 是遍历 SAN,还是只查看 CN?
-
试试这个查看证书:
$ openssl s_client -tls1 -starttls smtp -connect smtp.gmail.com:587 -servername smtp.gmail.com 2>/dev/null | openssl x509 -text -noout.
标签: ruby-on-rails ruby-on-rails-3.2 openssl actionmailer