- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在过去的 2 天里,我想我已经浏览了每一个可用的(google'able)帖子关于这个与 Net::HTTP
相关的 SSL 错误:OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A
我首先尝试做的是连接到 EtherPad
服务器 (https://test.titanpad.com),登录并使用 rubygems & 下载 zip 存档 Mechanize ;然而,不幸的是,由于所说的 SSL-Error
,我什至没有做到这一点。在尝试从 Mechanize 对象中调试问题后(例如,通过在脚本中手动设置 cert、ca_file、cert_store、verify_mode 等),我更接近实际问题,试图连接到 https://test.titanpad.com通过简单地使用 Net::HTTP
:
(在这个例子中,我首先连接到 https://encrypted.google.com 以确保 SSL
应该 成功;连接到 EtherPad 服务器的尝试从第 6 行开始)
irb(main):001:0> require 'net/https'
=> true
irb(main):002:0> google = Net::HTTP.new('encrypted.google.com', 443)
=> #<Net::HTTP encrypted.google.com:443 open=false>
irb(main):003:0> google.use_ssl = true
=> true
irb(main):004:0> google.ca_file = '/opt/local/share/curl/curl-ca-bundle.crt' if File.exists?('/opt/local/share/curl/curl-ca-bundle.crt')
=> "/opt/local/share/curl/curl-ca-bundle.crt"
irb(main):005:0> google.request_get('/')
=> #<Net::HTTPOK 200 OK readbody=true>
irb(main):006:0> etherpad = Net::HTTP.new('test.titanpad.com', 443)
=> #<Net::HTTP test.titanpad.com:443 open=false>
irb(main):007:0> etherpad.use_ssl = true
=> true
irb(main):008:0> etherpad.ca_file = '/opt/local/share/curl/curl-ca-bundle.crt' if File.exists?('/opt/local/share/curl/curl-ca-bundle.crt')
=> "/opt/local/share/curl/curl-ca-bundle.crt"
irb(main):009:0> etherpad.request_get('/')
OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:799:in `connect'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:799:in `block in connect'
from /opt/local/lib/ruby1.9/1.9.1/timeout.rb:54:in `timeout'
from /opt/local/lib/ruby1.9/1.9.1/timeout.rb:99:in `timeout'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:799:in `connect'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:755:in `do_start'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:744:in `start'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:1284:in `request'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:1195:in `request_get'
from (irb):9
from /opt/local/bin/irb:12:in `<main>'
即使在使用 verify_mode OpenSSL::SSL::VERIFY_NONE
时,OpenSSL 也会退出:
irb(main):010:0> etherpad.verify_mode = OpenSSL::SSL::VERIFY_NONE
=> 0
irb(main):011:0> etherpad.request_get('/')
OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv2/v3 read server hello A
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:799:in `connect'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:799:in `block in connect'
from /opt/local/lib/ruby1.9/1.9.1/timeout.rb:54:in `timeout'
from /opt/local/lib/ruby1.9/1.9.1/timeout.rb:99:in `timeout'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:799:in `connect'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:755:in `do_start'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:744:in `start'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:1284:in `request'
from /opt/local/lib/ruby1.9/1.9.1/net/http.rb:1195:in `request_get'
from (irb):11
from /opt/local/bin/irb:12:in `<main>'
在进一步研究 openssl 本身之后,事实证明在这种情况下真正的麻烦是必须强制使用 SSLv3 才能与 titanpad 后面的 Jetty 6.1.20 服务器
握手。开始工作:
irb(main):001:0> require 'net/https'
=> true
irb(main):002:0> etherpad = Net::HTTP.new('test.titanpad.com', 443)
=> #<Net::HTTP test.titanpad.com:443 open=false>
irb(main):003:0> etherpad.use_ssl = true
=> true
irb(main):004:0> etherpad.ssl_version = "SSLv3"
=> "SSLv3"
irb(main):005:0> etherpad.ca_file = '/opt/local/share/curl/curl-ca-bundle.crt' if File.exists?('/opt/local/share/curl/curl-ca-bundle.crt')
=> "/opt/local/share/curl/curl-ca-bundle.crt"
irb(main):006:0> etherpad.request_get('/')
=> #<Net::HTTPFound 302 Found readbody=true>
虽然这在使用 Net::HTTP
时显然有效,但没有这样的选项来设置 SSL
版本以在 Mechanize 中使用>...因此,如果有人能向我指出如何通过上述 gem o.O 强制执行 SSLv3,我将非常高兴
再次感谢!
系统:Mac OSX 10.6.8 ruby 1.9.3p0(2011-10-30 修订版 33570)[x86_64-darwin10]安装了 mechanize 的 rubygems:domain_name (0.5.2)、mechanize (2.1.1)、net-http-digest_auth (1.2)、net-http-persistent (2.4.1)、nokogiri (1.5.0)、ntlm-http ( 0.1.1), unf (0.0.4), unf_ext (0.0.4), 网络机器人 (0.0.13)
最佳答案
已通过将 ssl_version 功能从 Net::HTTP(通过 net-http-persistent)移植到 Mechanize v. 2.1.2(参见 https://github.com/tenderlove/mechanize/commit/4a228899855e0676ab69c2bf548170c8717465d8)得到修复。
关于ruby - 将 mechanize(甚至 Net::HTTP)与 ruby 1.9 一起使用会返回 'OpenSSL::SSL::SSLError' - 如何强制使用 SSLv3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9150032/
您好,我正在尝试通过执行从表存储帐户查询数据的 python 脚本来开始 Azure ML 算法。我用这个来做: entities_Azure=table_session.query_entities
我有一个运行 omniauth-facebook 和 omniauth-twitter 的 Rails 4 应用程序,但所有登录尝试都会遇到 Faraday::SSLError -- SSL_conn
我在 python 中使用一个包,我试图通过简单的打印访问方法我想出了这个错误 ConnectionError: HTTPSConnectionPool(host='xxx.xxxxx.xxx', p
import sslcontext = ssl.create_default_context()context.load_cert_chain('cert.pem', 'key.pem') B
尝试使用 the SnapWrap library 时我遇到过这个错误: File "/usr/local/lib/python2.7/dist-packages/requests-2.7.0-p
我正在编写一个涉及 CAS、jspring 安全检查、重定向等的简单脚本。我想使用 Kenneth Reitz 的 python 请求,因为它很棒!但是,CAS 需要通过 SSL 进行验证,所以我必须
我有一个带有 letsencrypt 证书的 python3 django 网站 一切正常,除了使用 python 请求到本地地址: response = requests.post('http://
我正在编写一个涉及 CAS、jspring 安全检查、重定向等的简单脚本。我想使用 Kenneth Reitz 的 python 请求,因为它很棒!但是,CAS 需要通过 SSL 进行验证,所以我必须
尝试使用 Requests session 发出简单的获取请求,但我不断收到特定站点的 SSLerror。我认为问题可能出在网站上(我使用 https://www.ssllabs.com 进行了扫描,
我正在尝试通过 python 向 iPhone 发送推送通知,如 here 所述但我收到以下错误: Traceback (most recent call last): File "", line
我正在编写一个涉及 CAS、jspring 安全检查、重定向等的简单脚本。我想使用 Kenneth Reitz 的 python 请求,因为它是一项很棒的工作!但是,CAS 需要通过 SSL 进行验证
这是我检查链接的功能。但是当链接是假的时它会抛出一个错误。例如,它适用于 twitter.com 但不适用于 twitt.com。 class Quality_Check: def check
我正在分析加密货币市场数据并使用某些交易所的公共(public) API。该程序每隔几秒发出一次 HTTPS 请求。奇怪的是,它恰好发出了 336 个请求,而在 337 个请求上它总是失败: /.rb
我正在尝试开始使用 PRAW,但在使用 login() 时遇到问题。 我有以下代码: import praw r = praw.Reddit('This is a test bot') r.login
我想使用从服务器生成的证书从我的客户端向服务器进行身份验证。我有一个 server-ca.crt,下面是正在运行的 CURL 命令。如何使用 python 请求模块发送类似的请求。 $ curl -X
我正在使用带有以下代码的 authlib: session = OAuth2Session(client_id, client_secret) token = session.fetch_access
我想使用从服务器生成的证书从我的客户端向服务器进行身份验证。我有一个 server-ca.crt,下面是正在运行的 CURL 命令。如何使用 python 请求模块发送类似的请求。 $ curl -X
当我尝试执行“conda update conda”时,我遇到了这个错误: 请你帮帮我! 最佳答案 如果您在防火墙或代理后面,您可能必须在您的 condarc 中将 ssl_verify 设置为 fa
我有包含 4 行的 fiddle.py import requests url = "https://randomuser.me/api/" locations = requests.get(url,
我不能在 Python 中使用不同的代理。 我的代码: import requests proxies = { "https":'https://154.16.202.22:3128',
我是一名优秀的程序员,十分优秀!