[英]Ruby Imap OpenSSL::SSL::SSLError: read server certificate B: certificate verify failed
I am trying to use IMAP and it does not work.我正在尝试使用 IMAP,但它不起作用。 I tried the same with 'https' and it worked.
我用“https”尝试了同样的方法,它奏效了。
require 'net/imap'
=> true
irb(main):002:0> Net::IMAP.new("xxx", 993, true).login("redmine", "redmine")
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
from /usr/local/lib/ruby/1.9.1/net/imap.rb:1439:in `connect'
from /usr/local/lib/ruby/1.9.1/net/imap.rb:1439:in `start_tls_session'
from /usr/local/lib/ruby/1.9.1/net/imap.rb:1036:in `initialize'
from (irb):2:in `new'
from (irb):2
from /usr/local/bin/irb:12:in `<main>'
irb(main):003:0>
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
gem -v 1.8.24
This is similar to: https://www.chiliproject.org/boards/1/topics/2076这类似于: https : //www.chiliproject.org/boards/1/topics/2076
openssl s_client -connect klevas.mif.vu.lt:imaps
shows that the certificate expired.显示证书已过期。 However, on another system, where Ruby and Gem are the same, the IMAP connection works.
但是,在 Ruby 和 Gem 相同的另一个系统上,IMAP 连接有效。
试试这个: imap = Net::IMAP.new('xxx', {:ssl => {:verify_mode => 0 }})
If we are discussing redmine here the following was helpful.如果我们在这里讨论 redmine,以下内容会有所帮助。
In lib/redmine/imap.rb on line 29 there was a call在第 29 行的 lib/redmine/imap.rb 中有一个电话
imap = Net::IMAP.new(host, port, ssl)
according to the information learned from /usr/lib/ruby/1.9.1/net/imap.rb根据从/usr/lib/ruby/1.9.1/net/imap.rb中了解到的信息
def initialize(host, port_or_options = {},
usessl = false, certs = nil, verify = true)
I changed it to我把它改成
imap = Net::IMAP.new(host, port, ssl, nil, false)
and the error was gone并且错误消失了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.