[英]Can't bypass OpenSSL verification - certificate verify failed (OpenSSL::SSL::SSLError)
I am trying to parse an HTTPS XML feed via Nokogiri but I get this OpenSSL error: 我试图通过Nokogiri解析HTTPS XML提要但我收到此OpenSSL错误:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
I can also see the SSL_CERT_FILE: 我也可以看到SSL_CERT_FILE:
echo $SSL_CERT_FILE
/home/user/certs/cacert.pem
This is how I am trying to parse: 这就是我试图解析的方式:
@feed = "https://example.com/feed1.xml"
doc = Nokogiri::XML(open(@feed)
I tried to bypass the OpenSSL verification, but I still get the same error: 我试图绕过OpenSSL验证,但我仍然得到同样的错误:
doc = Nokogiri::XML(open(@feed,{ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}))
Can anyone help? 有人可以帮忙吗?
This problem usually appears on Windows. 此问题通常出现在Windows上。
One quick solution is to pass ssl_verify_mode
to open 一个快速的解决方案是将
ssl_verify_mode
传递给open
require 'open-uri'
require 'openssl'
open(some_url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
Another quick one is overriding OpenSSL::SSL::VERIFY_PEER
in the beginning of your script by doing 另一个快速的方法是在脚本的开头重写
OpenSSL::SSL::VERIFY_PEER
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
Those who want real solution can try method described on https://gist.github.com/fnichol/867550 想要真正解决方案的人可以尝试https://gist.github.com/fnichol/867550上描述的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.