使用 RVM 安装 Ruby 1.9.2 时出现 Curl 证书错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6414232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 01:26:18  来源:igfitidea点击:

Curl Certificate Error when Using RVM to install Ruby 1.9.2

ruby-on-railscurlrvm

提问by Will Dennis

RVM is running into a certificate error when trying to download Ruby 1.9.2. It looks like curlis having a certificate issue but I am not sure how to bypass it. I have included the exact error info below.

尝试下载 Ruby 1.9.2 时,RVM 遇到证书错误。看起来curl有证书问题,但我不知道如何绕过它。我在下面包含了确切的错误信息。

$ rvm install 1.9.2
Installing Ruby from source to: /Users/willdennis/.rvm/rubies/ruby-1.9.2-p180, this may take a while depending on your cpu(s)...

ruby-1.9.2-p180 - #fetching 
ERROR: Error running 'bunzip2 '/Users/willdennis/.rvm/archives/ruby-1.9.2-p180.tar.bz2'', please read /Users/willdennis/.rvm/log/ruby-1.9.2-p180/extract.log
ruby-1.9.2-p180 - #extracting ruby-1.9.2-p180 to /Users/willdennis/.rvm/src/ruby-1.9.2-p180
ruby-1.9.2-p180 - #extracted to /Users/willdennis/.rvm/src/ruby-1.9.2-p180
Fetching yaml-0.1.3.tar.gz to /Users/willdennis/.rvm/archives

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
ERROR: There was an error, please check /Users/willdennis/.rvm/log/ruby-1.9.2-p180/*.log. Next we'll try to fetch via http.
Trying http:// URL instead.

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
ERROR: There was an error, please check /Users/willdennis/.rvm/log/ruby-1.9.2-p180/*.log
Extracting yaml-0.1.3.tar.gz to /Users/willdennis/.rvm/src
ERROR: Error running 'tar zxf /Users/willdennis/.rvm/archives/yaml-0.1.3.tar.gz -C /Users/willdennis/.rvm/src --no-same-owner', please read /Users/willdennis/.rvm/log/ruby-1.9.2-p180/yaml/extract.log
/Users/willdennis/.rvm/scripts/functions/packages: line 55: cd: /Users/willdennis/.rvm/src/yaml-0.1.3: No such file or directory
Configuring yaml in /Users/willdennis/.rvm/src/yaml-0.1.3.
ERROR: Error running ' ./configure --prefix="/Users/willdennis/.rvm/usr"  ', please read /Users/willdennis/.rvm/log/ruby-1.9.2-p180/yaml/configure.log
Compiling yaml in /Users/willdennis/.rvm/src/yaml-0.1.3.
ERROR: Error running '/usr/bin/make ', please read /Users/willdennis/.rvm/log/ruby-1.9.2-p180/yaml/make.log
Installing yaml to /Users/willdennis/.rvm/usr
ERROR: Error running '/usr/bin/make install', please read /Users/willdennis/.rvm/log/ruby-1.9.2-p180/yaml/make.install.log
ruby-1.9.2-p180 - #configuring 
ERROR: Error running ' ./configure --prefix=/Users/willdennis/.rvm/rubies/ruby-1.9.2-p180 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/willdennis/.rvm/usr ', please read /Users/willdennis/.rvm/log/ruby-1.9.2-p180/configure.log
ERROR: There has been an error while running configure. Halting the installation.

How can I resolve or avoid this error?

如何解决或避免此错误?

回答by jwadsack

In case any one else comes across this while trying to update to 1.9.3 (although version probably doesn't matter), check the version of rvm that you have. Wayne seems to have moved from rvm.beginrescueend.com to rvm.io. The old site's security certificate has expired, so curl's response is correct.

如果其他人在尝试更新到 1.9.3 时遇到此问题(尽管版本可能无关紧要),请检查您拥有的 rvm 版本。Wayne 似乎已经从 rvm.beginrescueend.com 转移到了 rvm.io。旧站点的安全证书已过期,因此 curl 的响应是正确的。

Updating rvm from the new site fixed this problem and allowed me to move forward.

从新站点更新 rvm 解决了这个问题,并允许我继续前进。

$ \curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled

Update: As @rodgerdpack mentioned, the command changes and I've updated the above. In general, see https://rvm.io/for the latest.

更新:正如@rodgerdpack 提到的,命令发生了变化,我已经更新了上述内容。一般情况下,请参阅https://rvm.io/以获取最新信息。

回答by DanielaWaranie

If do not want to change the scriptAND you do not want to add a cert "for ever"to the cert bundle. There is a very nice and quick solution:

如果不想更改脚本并且您不想将证书“永远”添加到证书包中。有一个非常好的和快速的解决方案:

#to download the cert
wget http://curl.haxx.se/ca/cacert.pem
#to let curl use it for the next calls
export CURL_CA_BUNDLE=~/cacert.pem

Then run your script. To reset the environment variable (for subsequent script calls that should not use this cert) re-login to your system or unset the environment variable:

然后运行你的脚本。要重置环境变量(对于不应使用此证书的后续脚本调用),请重新登录到您的系统或取消设置环境变量:

export CURL_CA_BUNDLE=

回答by Richard Fairhurst

Curl is invoked in .rvm/scripts/fetch, which by default will be in your home directory.

Curl 在 .rvm/scripts/fetch 中调用,默认情况下它将在您的主目录中。

Edit this using your favourite text editor: for example,

使用您最喜欢的文本编辑器编辑它:例如,

 nano ~/.rvm/scripts/fetch

In lines 56 and 58 (may vary with other versions of RVM, of course) you'll see two lines which begin

在第 56 行和第 58 行(当然,可能会因 RVM 的其他版本而异)您将看到两行开始

 fetch_command="curl ...

Simply add -k after curl, save and try again.

只需在 curl 后添加 -k,保存并重试。

回答by dbikard

You need to download the ca certificate from http://curl.haxx.se/ca/cacert.pemand add them to your curl-ca-bundle-new.crt file.

您需要从http://curl.haxx.se/ca/cacert.pem下载 ca 证书并将它们添加到您的 curl-ca-bundle-new.crt 文件中。

To find the location of this file use:

要查找此文件的位置,请使用:

   $ curl-config --ca

   /usr/share/curl/curl-ca-bundle.crt

Backup your curl-ca-bundle.crt file:

备份您的 curl-ca-bundle.crt 文件:

$ cp /usr/share/curl/curl-ca-bundle.crt /usr/share/curl/curl-ca-bundle.crt.old

Then you want to concatenate the two file using:

然后你想使用以下方法连接两个文件:

$ cat cacert.pem /usr/share/curl/curl-ca-bundle.crt >> curl-ca-bundle-new.crt

回答by Nick Messick

Perhaps all these complicated solutions were once necessary, but now all you need to do is first upgrade RVM and your problem will be solved:

也许所有这些复杂的解决方案曾经都是必需的,但现在您需要做的就是先升级 RVM,您的问题将得到解决:

$ rvm get stable
$ rvm reload
$ rvm install ruby-1.9.3-p194

回答by Vojto

If you don't mind disabling certificate check in curl (I don't):

如果您不介意在 curl 中禁用证书检查(我不介意):

echo insecure > ~/.curlrc

回答by Serge Seletskyy

On Centos 5.6 (Final) I had a problem with installing rvm 1.9.2 The error was:

在 Centos 5.6 (Final) 上我在安装 rvm 1.9.2 时遇到问题错误是:

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
ERROR: There was an error, please check /usr/local/rvm/log/ruby-1.9.2-p290/*.log. Next we'll try to fetch via http.
Trying http:// URL instead.

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
ERROR: There was an error, please check /usr/local/rvm/log/ruby-1.9.2-p290/*.log
ERROR: There has been an error while trying to fetch the source.  
Halting the installation.
ERROR: There has been an error fetching the ruby interpreter. Halting the installation.

Here is a list of actions which helped me to solve the problem

这是帮助我解决问题的操作列表

$ curl-config --ca # show path to the certificate
/usr/local/share/curl/curl-ca-bundle.crt
$ cd /usr/local/share/curl/ # go to that path
$ cp curl-ca-bundle.crt curl-ca-bundle.crt.bak # backup certificate
$ curl http://curl.haxx.se/ca/cacert.pem -o curl-ca-bundle.crt # download new
$ rvm install 1.9.2 # bingo it works

Btw curl version is curl 7.18.0 (to check '$ curl -V')

顺便说一句 curl 版本是 curl 7.18.0(检查'$ curl -V')

回答by jerikl

I was attempting to install ruby-1.9.2-p290and came across the same problem. After running which curland realizing that the curl instance was coming from an installation of MAMP on my system (OS X Snow Leopard), I reconfigured my PATHvariable to use the system default at /usr/bin/curl. Using this version, curl 7.19.7, I had no problem installing the latest version of Ruby with RVM.

我试图安装ruby-1.9.2-p290并遇到了同样的问题。在运行which curl并意识到 curl 实例来自我的系统 (OS X Snow Leopard) 上的 MAMP 安装后,我重新配置了我的PATH变量以使用系统默认值/usr/bin/curl. 使用此版本,curl 7.19.7我可以使用 RVM 安装最新版本的 Ruby。

回答by dorothy Dorothy

I had trouble installing 1.9.2 using RVM, here is my solution:

我在使用 RVM 安装 1.9.2 时遇到问题,这是我的解决方案:

I still got the file not found error but the installation went on to be successful

我仍然收到找不到文件的错误,但安装继续成功

[2011-07-05 14:24:07] tar zxf /Users//.rvm/archives/yaml-0.1.3.tar.gz -C /Users//.rvm/src --no-same-owner tar (child): /Users//.rvm/archives/yaml-0.1.3.tar.gz: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error exit delayed from previous errors

[2011-07-05 14:24:07] tar zxf /Users//.rvm/archives/yaml-0.1.3.tar.gz -C /Users//.rvm/src --no-same-owner tar (子):/Users//.rvm/archives/yaml-0.1.3.tar.gz:无法打开:没有这样的文件或目录 tar(子):错误不可恢复:现在退出 tar:子返回状态 2 tar : 错误退出延迟从以前的错误

回答by Duke3D

Thank you Dorothy - this recipe worked for me with the following minor modifications for a Win7 environment:

谢谢多萝西 - 这个食谱对我有用,对 Win7 环境做了以下小的修改:

For others with this issue -

对于其他有此问题的人 -

  1. Appreciate the discussion about updating the CA_Bundle - Good to do but it didn't help with this issue - the pyyaml website cert will still cause CURL to throw an error and since CURL is launched within the installer, no way to add a -k option.

  2. Ruby 1.9.2-p290 is trying to install YAML 0.1.4 so Google for a mirror and download that version - YAML-0.1.3 will have no effect in bypassing the issues.

  3. You need to do the windows equivalent of CHMOD 777 - within the rvm/src folder to the extracted files. Change security so that everyone has ownership/all privileges and turn off the read-only attribute for all files and folders.

  1. 感谢有关更新 CA_Bundle 的讨论 - 很好,但对这个问题没有帮助 - pyyaml 网站证书仍会导致 CURL 抛出错误,并且由于 CURL 在安装程序中启动,无法添加 -k 选项.

  2. Ruby 1.9.2-p290 正在尝试安装 YAML 0.1.4,所以谷歌搜索镜像并下载该版本 - YAML-0.1.3 将无法绕过这些问题。

  3. 您需要在 rvm/src 文件夹中对提取的文件执行相当于 CHMOD 777 的 Windows。更改安全性,以便每个人都拥有所有权/所有权限,并关闭所有文件和文件夹的只读属性。

The installer will still throw errors when it tries to download (CURL error), but will resume by trying to extract. The extraction will throw errors because the tarball is already extracted to the src folder. The next step of configuring YAML should work without errors if permissions in step 3 were set correctly and the installation should complete without further problems. (If installing via cygwin/bash, you will need to add a C compiler like 'gcc' and add 'ncurses' (tput command) and 'make' to the default core cygwin setup options.)

安装程序在尝试下载时仍会抛出错误(CURL 错误),但会通过尝试提取来恢复。提取将抛出错误,因为 tarball 已经提取到 src 文件夹。如果第 3 步中的权限设置正确,那么配置 YAML 的下一步应该可以正常工作,并且安装应该可以完成而不会出现其他问题。(如果通过 cygwin/bash 安装,则需要添加一个 C 编译器,如“gcc”,并将“ncurses”(tput 命令)和“make”添加到默认的核心 cygwin 设置选项。)