“证书验证失败"使用 Ruby 1.9.3 时出现 OpenSSL 错误 [英] "Certificate verify failed" OpenSSL error when using Ruby 1.9.3

查看:19
本文介绍了“证书验证失败"使用 Ruby 1.9.3 时出现 OpenSSL 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Mac OS 10.6.8(使用 rvm 安装)上使用 Ruby 1.9.3p0.当我尝试使用 托管在 GitHub 上的应用程序模板 创建新的 Rails 应用程序时,(例如):

<前>$ rails new myapp -m https://github.com/RailsApps/rails3-application-templates/raw/master/rails3-mongoid-devise-template.rb -T -O

我收到此错误消息:

/Users/me/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799:in `connect': SSL_connect返回=1 errno=0 state=SSLv3 读取服务器证书B:证书验证失败(OpenSSL::SSL::SSLError)

我了解 Ruby 语言解释器正在使用 OpenSSL 连接到 GitHub 以请求应用程序模板文件.GitHub 要求使用 SSL 进行所有连接.连接失败,因为 OpenSSL 无法验证服务器证书.

我通过下载证书文件解决了这个问题:

$ cd/opt/local/etc/openssl$ sudo curl -O http://curl.haxx.se/ca/cacert.pem$ sudo mv cacert.pem cert.pem

我使用 Ruby 1.9.2 没有问题.为什么我会遇到 Ruby 1.9.3 的证书验证失败"问题?这是 Ruby 1.9.3 的错误吗?它特定于 Mac OS 10.6.8 吗?我的解决方案是解决这个问题的正确方法吗?

解决方案

正确答案涉及许多活动部分.取决于您的操作系统、Ruby 版本、OpenSSL 版本、Rubygems 版本.我在研究后最终写了一篇文章.我的文章解释了错误的原因,提供了进一步诊断的步骤,展示了几种解决方法,并提出了可能的解决方案.这会很有帮助:

OpenSSL 错误和 Rails – 证书验证失败

还有指向 GitHub 上相关提交和问题的链接.

I'm using Ruby 1.9.3p0 on Mac OS 10.6.8 (installed using rvm). When I attempt to create a new Rails application using an application template hosted on GitHub, with this (for example):

$ rails new myapp -m https://github.com/RailsApps/rails3-application-templates/raw/master/rails3-mongoid-devise-template.rb -T -O

I get this error message:

/Users/me/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799:in `connect': SSL_connect 
returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed 
(OpenSSL::SSL::SSLError)

I understand the Ruby language interpreter is using OpenSSL to connect to GitHub to request the application template file. GitHub requires all connections to be made using SSL. The connection failed because OpenSSL was unable to verify the server certificate.

I was able to resolve the issue by downloading a certificates file:

$ cd /opt/local/etc/openssl
$ sudo curl -O http://curl.haxx.se/ca/cacert.pem
$ sudo mv cacert.pem cert.pem

I had no problem using Ruby 1.9.2. Why did I get the "certificate verify failed" problem for Ruby 1.9.3? Is this a Ruby 1.9.3 bug? Is it specific to Mac OS 10.6.8? Is my solution the right way to resolve this?

解决方案

There are lots of moving parts involved in the correct answer. Depends on your OS, Ruby version, OpenSSL version, Rubygems version. I ended up writing an article after researching it. My article explains the reasons for the error, offers steps for further diagnosis, shows several workarounds, and suggests possible solutions. This will be helpful:

OpenSSL Errors and Rails – Certificate Verify Failed

There are also links to the relevant commits and issues on GitHub.

这篇关于“证书验证失败"使用 Ruby 1.9.3 时出现 OpenSSL 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆