如何解决“证书验证失败”的问题在 Windows 上?
我正在尝试使用 Signet 进行 Google 服务的 OAuth。并收到此错误:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
遵循以下问题:
看来解决方案是修复ca_path
或为SSL 设置。VERIFY_NONE
发布的 ca_path 修复仅适用于 Linux(端口安装),而 VERIFY_NONE 的修复似乎适用于法拉第。
Windows/signet gem 有解决方案吗?
I am trying to use signet for OAuth to Google services. And get this error:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
Following these questions:
- SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
- OmniAuth & Facebook: certificate verify failed
Seems the solution is either to fix ca_path
or to set .VERIFY_NONE
for SSL
The ca_path
fix posted only works on Linux (port install) and the fix for VERIFY_NONE
seems to be for faraday.
Is there a solution for Windows/signet gem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
实际上,我发现在 Windows 中为 Ruby 本身(而不仅仅是一个 gem)解决此问题的最佳方法是执行以下操作:
创建一个新的系统变量:
变量:SSL_CERT_FILE
值:C:\RailsInstaller\cacert.pem
关闭所有命令提示符,包括 Rails 服务器命令提示符等。
启动新的 ruby irb 提示符,然后尝试以下操作:
现在应该一切正常了。
Actually the best way I found to solve this in windows for Ruby itself, not just one gem, is to do the following:
Create a new System Variable:
Variable: SSL_CERT_FILE
Value: C:\RailsInstaller\cacert.pem
Close all your command prompts, including your Rails server command prompt, etc.
Start a new ruby irb prompt, and try the following:
It should all work now just fine.
Windows 解决方案,我从几个不同的答案中拼凑而成:
中config/initializers/omniauth.rb:
<块引用>
<前><代码>#config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder 做
提供商:facebook,CUSTOMER_KEY,CUSTOMER_SECRET,{client_options:{ssl:{ca_file:Rails.root.join('lib/assets/cacert.pem').to_s}}}
结尾
显然,重新启动您的服务器。
脚注:
您也许可以删除 cacert.pem 文件中的许多不必要的证书以减小大小。如果您只需要此解决方案进行开发,则可以将该文件保存在项目之外,并使用 client_options hash_
else
_provider 执行if Rails.env.development?
_provider 行没有 client_options hash_end
的行Solution for Windows, which I cobbled together from a few different answers:
In config/initializers/omniauth.rb:
Obviously, restart your server.
Footnotes:
You might be able to cut out a lot of the unnecessary certificates in the cacert.pem file to reduce the size. If you only need this solution for development, you could save the file outside of your project and do a
if Rails.env.development?
_provider line with the client_options hash_else
_provider line without client_options hash_end
经过大量搜索和浪费时间后,我找到了一个非常简单的解决方案来解决 Windows 中的 Ruby 中的这个问题。
两个简单的步骤:
在命令提示符中写入:
C:\gem install Certified
在您的
rb
文件中添加:require 'certified'
就是这样。
After too much searching and wasted time, I found a very simple solution to fix this issue in Ruby with Windows.
Two simple steps:
In command prompt write:
C:\gem install certified
In your
rb
file add:require 'certified'
That's it.
更新 rubygems 包管理框架在 Windows 7 上为我解决了这个问题。
https://rubygems.org/pages/download
Updating the rubygems package management framework solved this issue for me on Windows 7.
https://rubygems.org/pages/download
是的,我已将初始化程序文件夹中的omniouth.rb 文件设置为:
现在这似乎工作正常。但不要将其用于生产。
yes, I've set the omniouth.rb file in the initializers folder to this:
and this seems to work fine now. But don't use this for production.
使用 http:// URL 而不是 https:// 可以让您更轻松地
将 gem 源更改为 http://rubygems.org / 通过在 ruby 命令行上使用以下命令行
Using the http:// URL instead of https:// make this easier to you
Change the gem source to http://rubygems.org/ by using the following line of command on your ruby command line
添加到 DevDude 的解决方案,但使用 Windows Powershell:
在 powershell 提示符下:
$env:SSL_CERT_FILE = 'c:\RailsInstaller\cacert.pem'
然后我就能够成功运行
gem update
注意:您可以简单地在您的配置文件
notepad $profile
中定义该环境变量Adding onto DevDude's solution, but using Windows Powershell:
At the powershell prompt:
$env:SSL_CERT_FILE = 'c:\RailsInstaller\cacert.pem'
I was then able to run
gem update
successfullyNote: you can simply define that environment variable in your profile
notepad $profile
转到 rubygems-update 下载页面:https://rubygems.org/gems/rubygems-update
单击“下载”链接,您将下载一个名为 rubygems-update-2.6.7.gem 的文件。在命令行中,导航到您下载 .gem 文件的目录并输入:(
如果是较新的版本,则为任何文件名)
然后输入:
您可以使用以下命令验证它是否已更新:
Go to the rubygems-update download page: https://rubygems.org/gems/rubygems-update
Click on the Download link, and you'll download a file called rubygems-update-2.6.7.gem. At the command line, navigate to the directory you downloaded the .gem file to and type:
(or whatever the filename was, if a newer version)
Then type:
You can verify it's updated with:
我在尝试在 Windows 机器上设置 Rails 5 时遇到此错误,结果我必须将 rubygem 版本更新到 2.6.7,然后它就可以工作了。
第 1 步从下面下载 rubygem
第 2 步 - 通过指向下载的 rubygem 进行安装
第 3 步 - 检查新版本是 2.6.7
步骤4 - 现在安全地卸载 rubygems-update gem
第 5 步尝试再次安装 Rails 5
效果非常好!
我从以下地方得到信息:
http://guides.rubygems.org/ssl-certificate -update/#安装使用更新包
I had this error whilst trying to setup rails 5 on a windows machine, turns out I had to update the rubygem version to 2.6.7 and then it worked.
step 1 download rubygem from below
step 2 - install by pointing to downloaded rubygems
step 3 - check new version is 2.6.7
step 4 - now safely un-install rubygems-update gem
step 5 tried to install rails 5 again
worked like a charm!
I got info from:
http://guides.rubygems.org/ssl-certificate-update/#installing-using-update-packages
通过将证书导入为受信任的机构,我能够消除上面提到的路径或系统变量设置。
I was able to eliminate the PATH or SYSTEM VARIABLE setting mentioned above by importing the certificate as a Trusted Authority.
我相信正确的答案是更新您的 gem 安装程序:rubygems-update。关于为什么需要这样做的解释可以在以下位置找到:Ssl 证书更新
I believe the correct answer is to update your gem installer: rubygems-update. The explanation for why this is needed is found at: Ssl Certificate Updates
从 https://curl.haxx.se/ca/cacert.pem 保存 cacert.pmp 文件 然后将此文件添加到 ruby 安装文件夹\lib\ruby\2.3.0\rubygems\ssl_certs 的位置
,例如:C:\Ruby23\lib\ruby\2.3.0\rubygems\ssl_certs
save your cacert.pmp file from https://curl.haxx.se/ca/cacert.pem and then add this file to location yourruby-installation folder\lib\ruby\2.3.0\rubygems\ssl_certs
for example:C:\Ruby23\lib\ruby\2.3.0\rubygems\ssl_certs
这帮助了我:
https://coderwall.com/p/ubl6iw/fix-ssl_connect-returned-1-errno-0-state-sslv3-read-server-certificate-b-certificate-verify-失败-openssl-ssl-ssl错误
我的 ruby on Rails 项目正在内部将数据发布到 api,并且无法验证内部证书。
这些线路有帮助:
希望这能有所帮助。
This helped me:
https://coderwall.com/p/ubl6iw/fix-ssl_connect-returned-1-errno-0-state-sslv3-read-server-certificate-b-certificate-verify-failed-openssl-ssl-sslerror
My ruby on rails project is posting data to an api internally, and it cannot verify the internal certificate.
These lines helped:
Hope this can help.
当我安装旧版本的 ruby 时,我也遇到了这个问题。当我安装最新的 Ruby 版本时,这个问题就消失了。所以基本上 SSL 证书需要更新。
I was also facing this issue when I installed older ruby versions. When I installed the latest Ruby version this problem went away. So basically the SSL certificate needed to be updated.
对于使用 Rails 4 的人。
将其添加到 devise.rb 中
For people who are using rails 4.
Add this in devise.rb