首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >rails :在安装包时验证SSL证书的问题

rails :在安装包时验证SSL证书的问题
EN

Stack Overflow用户
提问于 2020-12-24 11:47:24
回答 1查看 5.3K关注 0票数 4

我是rails的新手,在使用这个命令rails new n_project创建我的第一个项目时,我得到了这个错误

代码语言:javascript
运行
复制
run  bundle install
Fetching source index from https://rubygems.org/

Retrying fetcher due to error (2/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see .... To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
Retrying fetcher due to error (3/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see .... To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
Retrying fetcher due to error (4/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see .... To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most
likely your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see ...

我尝试将Gemfile中的https更改为http,并且只执行bundle install,但问题没有得到解决。相反,这条消息会出现:

代码语言:javascript
运行
复制
Fetching gem metadata from http://rubygems.org/.
Retrying dependency api due to error (2/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://index.rubygems.org/api/v1/dependencies?gems=rails%2Csqlite3%2Cpuma%2Csass-rails%2Cuglifier%2Ccoffee-rails%2Cjquery-rails%2Cturbolinks%2Cjbuilder%2Cbyebug%2Cweb-console%2Ctzinfo-data.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see .... To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
Retrying dependency api due to error (3/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://index.rubygems.org/api/v1/dependencies?gems=rails%2Csqlite3%2Cpuma%2Csass-rails%2Cuglifier%2Ccoffee-rails%2Cjquery-rails%2Cturbolinks%2Cjbuilder%2Cbyebug%2Cweb-console%2Ctzinfo-data.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see .... To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
Retrying dependency api due to error (4/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://index.rubygems.org/api/v1/dependencies?gems=rails%2Csqlite3%2Cpuma%2Csass-rails%2Cuglifier%2Ccoffee-rails%2Cjquery-rails%2Cturbolinks%2Cjbuilder%2Cbyebug%2Cweb-console%2Ctzinfo-data.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see .... To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
EN

回答 1

Stack Overflow用户

发布于 2021-03-30 19:13:26

当我在谷歌上搜索同一个问题的答案时,你的问题出现了。我刚刚创建了一个新的rails项目,结果出现了错误。

代码语言:javascript
运行
复制
      remove  config/initializers/new_framework_defaults_5_1.rb
         run  bundle install
Fetching source index from https://rubygems.org/

Retrying fetcher due to error (2/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.o
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed forormation about OpenSSL certificates, see bitlylink. To connect without using SSL, edit your Gemfile sources and change 'https
Retrying fetcher due to error (3/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.o
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed forormation about OpenSSL certificates, see bitlylink. To connect without using SSL, edit your Gemfile sources and change 'https
Retrying fetcher due to error (4/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.o
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed forormation about OpenSSL certificates, see bitlylink. To connect without using SSL, edit your Gemfile sources and change 'https
Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most
likely your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see bitlylink. To connect
without using SSL, edit your Gemfile sources and change 'https' to 'http'.

希望你能解决你的问题,但我想我应该描述一下解决问题的步骤,以防其他人也有同样的问题。

该解决方案适用于Windows 10、Ruby2.3.3、Rails 5.1和Git-Bash。

我跟随了这个向导。https://bundler.io/v2.0/guides/rubygems_tls_ssl_troubleshooting_guide.html#automated-ssl-check

希望今后对SSL证书问题的任何更改和解决方案都在本指南中得到更新。

首先。编辑Gemfile并更改

代码语言:javascript
运行
复制
source 'https://rubygems.org' 

代码语言:javascript
运行
复制
source 'http://rubygems.org'

根本不起作用。

因此,根据指南:

步骤1.运行

代码语言:javascript
运行
复制
curl -Lks 'https://git.io/rg-ssl' | ruby

这只是向我表明,我不能通过SSL连接,所以没有特别的帮助。

步骤2.更新绑定器

代码语言:javascript
运行
复制
gem install bundler
ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=error: certificate verify failed (httppecs.4.8.gz)

由于SSL错误,这也失败了。

步骤3.更新Rubygems。

代码语言:javascript
运行
复制
gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

这也失败了。

步骤4.更新系统时钟。是的,不,我在窗户上所以不这么做。

这里是解决方案的起点:

步骤5.更新CA证书。向导要我下载一个证书文件。

代码语言:javascript
运行
复制
Download the .pem file from this link:  GlobalSignRootCA.pem

使用实际指南查找到证书的最新链接。我下载证书文件。

步骤5.1.在安装中找到RubyGems证书目录

代码语言:javascript
运行
复制
gem which rubygems

对我来说,目录是'C:\RailsInstaller\Ruby2.3.3\lib\ruby\2.3.0\rubygems\ssl_certs‘

步骤5.2.我将GlobalSignRootCA_R3.pem文件复制到这个目录中。

做完这件事后,我应该按照指南

按照最上面的指示自动更新RubyGems。

步骤5.3.因此,在我运行的目录中使用证书文件。

代码语言:javascript
运行
复制
gem update --system
ERROR:  Interrupted
Updating rubygems-update
Successfully installed rubygems-update-3.2.15
Parsing documentation for rubygems-update-3.2.15
Installing ri documentation for rubygems-update-3.2.15

这需要永远没有任何用户的反馈,所以我中断终端。但它似乎一直在做一些工作。

步骤5.4.然后,我尝试运行bundle install来下载和安装依赖项。

代码语言:javascript
运行
复制
bundle install
Fetching source index from https://rubygems.org/
Resolving dependencies...
Could not verify the SSL certificate for
https://rubygems.org/quick/Marshal.4.8/rails-5.1.7.gemspec.rz.
There is a chance you are experiencing a man-in-the-middle attack, but most
likely your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see a bitly link. To connect
without using SSL, edit your Gemfile sources and change 'https' to 'http'.

但我还是得到了一些SSL证书错误。

步骤5.5。然而,指南特别提到,邦德勒本身应该得到更新。所以我用

代码语言:javascript
运行
复制
gem install bundler
Successfully installed bundler-2.2.15
Parsing documentation for bundler-2.2.15
Installing ri documentation for bundler-2.2.15
Done installing documentation for bundler after 21 seconds
1 gem installed

并成功地进行更新。

步骤5.6.最后,我再次运行bundle install,它现在开始下载和安装依赖项,而没有任何ssl错误。

代码语言:javascript
运行
复制
bundle install
Fetching gem metadata from https://rubygems.org/.............
Resolving dependencies......
Fetching rake 13.0.3
Installing rake 13.0.3
Fetching concurrent-ruby 1.1.8
Installing concurrent-ruby 1.1.8
Fetching i18n 1.8.9
Installing i18n 1.8.9
Fetching minitest 5.14.4
Installing minitest 5.14.4
Using thread_safe 0.3.6
Fetching tzinfo 1.2.9
... and so on

额外:安装导致了一个sqlite3错误,这个错误用这里找到的信息解决了。How do I install SQLite3 while setting up Ruby on Rails?

在这一切之后。它已经开始运行了。

代码语言:javascript
运行
复制
$ rails server
   => Booting Puma
   => Rails 5.1.7 application starting in development
   => Run `rails server -h` for more startup options
   *** SIGUSR2 not implemented, signal based restart unavailable!
   *** SIGUSR1 not implemented, signal based restart unavailable!
   *** SIGHUP not implemented, signal based logs reopening unavailable!
   Puma starting in single mode...
   * Version 3.12.6 (ruby 2.3.3-p222), codename: Llamas in Pajamas
   * Min threads: 5, max threads: 5
   * Environment: development
   * Listening on tcp://localhost:3000
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65437894

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档