当我生成新的 Rails 应用程序时出现此错误

当我生成新的 Rails 应用程序时出现此错误
Fetching source index from https://rubygems.org/
Retrying source fetch due to error (2/3): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for rubygems.
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 bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
Retrying source fetch due to error (3/3): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for ruby gem.
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 bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
Could not verify the SSL certificate for rubygems.
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 bit.ly/ruby-ssl. To connect without
using SSL, edit your Gemfile sources and change 'https' to 'http'.
         run  bundle exec spring binstub --all

我运行了gem update --system,但没有成功。我遇到了另一个错误:

ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

这是怎么回事?我该如何解决?谢谢

答案1

此问题通常发生在旧版本的 ruby​​gem 中。您可以尝试通过运行以下命令进行更新:

gem update --system --source http://rubygems.org/

在那之后

gem update

来源

答案2

.gemrc在您的主目录中创建一个新文件并添加此行。

:ssl_verify_mode: 0

现在,即使无法验证 SSL 连接是否“受信任”,它也应该继续。

相关内容