Linux 上的 Ruby 中使用 Net::HTTP 的 sslv3 警报非法参数
我正在尝试使用远程系统进行用户身份验证。当我在 MacOSX 上运行这段代码时,它会得到响应,但在我的机器上失败:
def create
uri = URI.parse('https://ourclient.example.com/')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new('/login.jsp')
request.set_form_data({'login_name' => params[:login], 'password' => params[:password]})
response = http.request(request)
puts "Response BODY: #{response.body.inspect}"
end
关闭验证可以消除 Mac 上的警告。在我的机器上,http.request 引发了这个异常:
OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert illegal parameter):
app/controllers/sessions_controller.rb:16:in `create'
我在没有 Rails 的情况下使用 IRB 得到了相同的行为。我昨天全新安装了 Fedora 14,安装了所需的开发工具和库。我正在使用 Ruby 1.9.2-p180 和 Rails 3.0.4。我以为我的库可能配置错误(我的 Fedora 12 已经升级了几次),但现在这是一个新安装。
远程系统可能是 Microsoft 的 IIS,但我不确定。也许我可以使用较旧的 SSL 协议,但我的 Google-fu 找不到咒语。
我将不胜感激有关解决此问题的任何提示。谢谢,
克里斯
I am attempting to use a remote system for user authentication. This chunk of code gets a response when I run it on MacOSX, but fails on my machine:
def create
uri = URI.parse('https://ourclient.example.com/')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new('/login.jsp')
request.set_form_data({'login_name' => params[:login], 'password' => params[:password]})
response = http.request(request)
puts "Response BODY: #{response.body.inspect}"
end
Turning verify off gets rid of a warning on the Macs. On my machine, the http.request raises this exception:
OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert illegal parameter):
app/controllers/sessions_controller.rb:16:in `create'
I get the same behavior using IRB without Rails. I did a clean install of Fedora 14 yesterday, installed the required development tools and libraries. I'm using Ruby 1.9.2-p180, and Rails 3.0.4. I thought I might have had my libraries misconfigured (I had Fedora 12 that had been upgraded a few times), but this is now a new install.
The remote system is probably Microsoft's IIS, but I'm not certain of that. Perhaps I can use an older SSL protocol, but my Google-fu can't find the incantation.
I would appreciate any tips on resolving this issue. Thanks,
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如何在服务器上创建 ssl 证书?自签名还是 ca 签名?
如果删除 VERIFY_NONE,您收到的错误是什么?
how was created the ssl cert on the server? self-signed or ca-signed?
which is the error you receive if you remove the VERIFY_NONE?
使用机械化宝石
并尝试
use Mechanize gem for it
and try