【问题标题】:Error while running an rails application from command prompt从命令提示符运行 rails 应用程序时出错
【发布时间】:2018-05-17 00:50:03
【问题描述】:

我在 Windows 8 中有带有 ruby​​ 版本“ruby 2.1.5p273(2014-11-13 修订版 48405)[i386-mingw32]”的 rails 4.1.8。我按照本教程在 rails-“http://installfest.railsbridge.org/installfest/windows 上安装 ruby​​” ”。现在,每当我运行任何 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 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 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 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 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 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 bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.

我应该将 https 更改为 http 吗?安全吗?

【问题讨论】:

    标签: ruby-on-rails


    【解决方案1】:

    正如错误消息所说:

    有关 OpenSSL 证书的信息,请参阅 bit.ly/ruby-ssl。

    bit.ly/ruby-ssl 指向http://railsapps.github.io/openssl-certificate-verify-failed.html,它对正在发生的事情进行了解释,并就如何修复它提出了建议。

    source 'http://rubygems.org' 中将https 更改为http 是推荐的解决方法之一。

    底部有windows专用解决方案推荐下载a cacert.pem for RailsInstaller

    【讨论】:

    • 我建议不要这样做,因为 http 不如 https 安全。
    • 我下载了 cacert.pem...它成功了!!非常感谢:)
    • 我也收到此错误 - DL 已弃用,请使用 Fiddle。为什么这样?我应该对此消息感到困扰吗?
    • 不确定新错误;可能值得添加一个新问题。
    【解决方案2】:

    这可以通过运行gem update --system来解决

    不久前我自己也遇到了同样的问题,并为我解决了这个问题。

    【讨论】:

    • 我试过这个,但它给了我一个错误-“错误:执行 gem ... (Gem::RemoteFetcher::FetchError) SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B : 证书验证失败 (rubygems.org/specs.4.8.gz)
    • 今天也遇到了同样的问题 - 跑了gem update --system,但得到了和@dips一样的错误
    • 我在尝试此更新以及其他更新(在 Windows 上)时遇到证书错误。我安装了新版本的 ruby​​ 2.5.x(旧版本是 2.2.x)。这解决了 ssl 证书问题。 Gem 是一个较新的版本。 Bundler 不在此安装中,但很容易从命令行安装。
    【解决方案3】:

    只需转到根目录中的 gem 文件,并将最上面一行中的“https”更改为“http”即可。

    【讨论】:

      【解决方案4】:

      将 https 更改为 http 只是自找麻烦,尤其是在生产机器上时。保安放在那里是有原因的。

      列出许多解决方案,从更新您的证书、更新您的 openssl 到根据更新的证书目录重建您的 ruby​​ 等等。

      但涵盖所有基础的一种解决方案是核爆你的 rvm:

      rvm implode
      brew uninstall openssl --force
      # now reinstall rvm for your system
      # install ruby 2.3.1 via rvm (at this point RVM will install openssl 1.0.2j via homebrew)
      # issue should be fixed.
      

      解决方案取自https://github.com/rubygems/rubygems/issues/1758

      【讨论】:

        【解决方案5】:

        我也有同样的问题。正如前面其他人所说。最简单的解决方案是

        • cacert.pem download link下载cacert.pem文件。
        • 将此文件保存到“C:\RailsInstaller\cacert.pem”。如果您正在尝试使用 redmine,您可以将其移动到 redmine 根文件夹。就我而言,我使用的是 bitnami redmine 堆栈,我将文件移动到“C:\Bitnami\redmine-3.3.2-2\apps\redmine\htdocs\ssl_certs”
        • 现在将系统环境变量设置为,

          Variable Name: SSL_CERT_FILE
          Value: C:\RailsInstaller\cacert.pem [My value was C:\Bitnami\redmine-3.3.2-2\apps\redmine\htdocs\ssl_certs]
          

        这对我有用。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-06-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-08-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多