Ruby 中的机械化和 SSLError
将 Mechanize 与我的 ruby 脚本一起使用,我无法解决众所周知的 SSLError。 我在 Rails 上运行 Windows 7 和 RailsInstaller。
我想用我的 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 = "[email protected]"
login_form.usr_pass = "mypassword"
page = a.submit( login_form, login_form.button_with( :value => "Login" )
现在,当我运行此代码时,它会显示 SSLError 状态
OpenSSL::SSL::SSLError: SSL_connect 返回=1 errno=0 state=SSLv3 读取服务器证书 B:证书验证失败
我还包含了来自 http://curl.haxx.se/ca/cacert.pem 像这样
a.ca_file "/RailsInstaller/cacert.pm"
或那样,
a.agent.http.ca_file "/RailsInstaller/cacert.pm"
但这两种解决方案都不起作用。
有人可以给我提示吗?
Using Mechanize with my ruby script, I can't get around the the well known SSLError.
I'm running on rails with Windows 7 and RailsInstaller.
I want to generate adcrun.ch links with my ruby script.
Therefore I have to login into my adcrun.ch account:
require 'mechanize'
a = Mechanize.new
page = a.get( "http://adcrun.ch" )
login_form = page.form_with( :action => "http://adcrun.ch/" )
login_form.usr_email = "[email protected]"
login_form.usr_pass = "mypassword"
page = a.submit( login_form, login_form.button_with( :value => "Login" )
Now when I run this code it shows me that SSLError state
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
I have also included the newest ca file from http://curl.haxx.se/ca/cacert.pem
like this
a.ca_file "/RailsInstaller/cacert.pm"
or that
a.agent.http.ca_file "/RailsInstaller/cacert.pm"
but neither of the solutions worked.
Can someone give me hints?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您应该使用
"https://adcrun.ch"
而不是"http://adcrun.ch"
。目前,您正在尝试在非安全端口上建立安全连接,因此,您将收到返回的“无效证书”,并且 OpenSSL 无法验证它。It looks like you should be using
"https://adcrun.ch"
instead of"http://adcrun.ch"
. Currently, you are trying to make a secure connection on a non-secure port, therefore, you are getting an "invalid cert" returned and OpenSSL can't verify it.