如何解决“证书验证失败"在 Windows 上? [英] How to solve "certificate verify failed" on Windows?
问题描述
我正在尝试将 Signet 用于 OAuth 到 Google 服务.并收到此错误:
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
以下问题:
似乎解决方案是修复 ca_path
或 set .VERIFY_NONE
for SSL
Seems the solution is either to fix ca_path
or to set .VERIFY_NONE
for SSL
发布的 ca_path
修复仅适用于 Linux(端口安装),VERIFY_NONE
的修复似乎适用于法拉第.
The ca_path
fix posted only works on Linux (port install) and the fix for VERIFY_NONE
seems to be for faraday.
Windows/signet gem 有解决方案吗?
Is there a solution for Windows/signet gem?
推荐答案
实际上,我发现在 Windows 中为 Ruby 本身解决此问题的最佳方法(不仅仅是一个 gem)是执行以下操作:
Actually the best way I found to solve this in windows for Ruby itself, not just one gem, is to do the following:
- 下载https://curl.haxx.se/ca/cacert.pem进入 c:\railsinstaller\cacert.pem.确保将其保存为 .pem 文件,而不是文本文件.
- 转到您的计算机 -> 高级设置 -> 环境变量
创建一个新的系统变量:
- Download https://curl.haxx.se/ca/cacert.pem into c:\railsinstaller\cacert.pem. Make sure you save it as a .pem file, rather than a text file.
- Go to your Computer -> Advanced Settings -> Environment Variables
Create a new System Variable:
变量:SSL_CERT_FILE值:C:\RailsInstaller\cacert.pem
Variable: SSL_CERT_FILE Value: C:\RailsInstaller\cacert.pem
关闭所有命令提示符,包括 Rails 服务器命令提示符等.
Close all your command prompts, including your Rails server command prompt, etc.
启动一个新的 ruby irb 提示符,然后尝试以下操作:
Start a new ruby irb prompt, and try the following:
$irb>require 'open-uri'
$irb>open('https://www.gmail.com')
现在应该一切正常.
这篇关于如何解决“证书验证失败"在 Windows 上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!