从命令提示符运行rails应用程序时出错

时间:2015-03-21 14:29:27

标签: ruby-on-rails

我在Windows 8中使用ruby版“ruby 2.1.5p273(2014-11-13修订版48405)[i386-mingw32]”的rails 4.1.8。我按照本教程在rails上安装ruby - “{{3 }}”。现在每当我运行任何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吗?它安全吗?

5 个答案:

答案 0 :(得分:2)

正如错误消息所示:

  

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

bit.ly/ruby-ssl指向http://railsapps.github.io/openssl-certificate-verify-failed.html,其中包含对正在发生的事情的解释,以及有关如何修复它的建议。

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

底部有一个特定于Windows的解决方案,建议下载a cacert.pem for RailsInstaller

答案 1 :(得分:1)

这可以通过运行gem update --system

来解决

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

答案 2 :(得分:1)

只需转到根目录中的gem文件,然后将“https”更改为最顶行的“http”。

答案 3 :(得分:0)

将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

答案 4 :(得分:0)

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

  • 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]
    

这对我有用。