【发布时间】:2012-02-07 01:28:13
【问题描述】:
在我的 ruby 脚本中使用 Mechanize,我无法绕过众所周知的 SSLError。 我正在使用 Windows 7 和 RailsInstaller 在 Rails 上运行。
我想用我的 ruby 脚本生成 adcrun.ch 链接。 因此,我必须登录我的 adcrun.ch 帐户:
require 'mechanize'
a = Mechanize.new
page = a.get( "http://adcrun.ch" )
login_form = page.form_with( :action => "http://adcrun.ch/" )
login_form.usr_email = "myem@il.com"
login_form.usr_pass = "mypassword"
page = a.submit( login_form, login_form.button_with( :value => "Login" )
现在,当我运行此代码时,它会显示 SSLError 状态
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
我还包含了来自http://curl.haxx.se/ca/cacert.pem 的最新 ca 文件 像这样
a.ca_file "/RailsInstaller/cacert.pm"
或者那个
a.agent.http.ca_file "/RailsInstaller/cacert.pm"
但两种解决方案均无效。
有人可以给我提示吗?
【问题讨论】:
-
按原样使用您的代码对我有用。唯一的区别是我在 Linux 上。适用于 1.8.7 和 1.9.3。可能是 URL 是 http 而不是 https。
标签: ruby-on-rails ruby ssl mechanize