Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing curl with ssl so I can install homebrew

The Solution

I used Bruno's post to find the solution, but feel that it needs to be made more concrete, so this is explicitly what I did.

  1. Downloaded cacert.pem into my ~/.ssh dir (I don't know if this is where it should go, but I saw someone do something similar while trying to find a solution, so this is where I put it).
  2. Set the env var CURL_CA_BUNDLE for the installation. This is actually solution number 4 from the website suggested by the failure. I just misunderstood what they were saying (a simple example might have saved me hours of confusion). Anyway, you'll need to specify the full path to the .pem file, then you can install like this $ CURL_CA_BUNDLE=~/.ssh/cacert.pem ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)" And then it is installed!

The Original Question

How do I either

  1. install homebrew, or
  2. install curl with SSL so that I can install homebrew?

I'm on Mac OSX Leopard.

I'm trying to install homebrew, but I get the following error:

$ ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/Formula/...
/usr/local/Library/Homebrew/...
==> The following directories will be made group writable:
/usr/local/bin
/usr/local/lib
/usr/local/lib/pkgconfig
/usr/local/share/man/man1
/usr/local/share/man/man3

Press enter to continue
==> /usr/bin/sudo /bin/chmod g+w /usr/local/bin /usr/local/lib /usr/local/lib/pkgconfig /usr/local/share/man/man1 /usr/local/share/man/man3
==> Downloading and Installing Homebrew...
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.

gzip: stdin: unexpected end of file
/usr/bin/tar: Child returned status 1
/usr/bin/tar: Error exit delayed from previous errors
Failed during: /bin/bash -o pipefail -c '/usr/bin/curl -sSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1'

I tried installing curl with macports and specifying +ssl, but that didn't work (sorry, I don't remember what the error was, and it took about an hour to get to that point, so I don't want to do it again). I uninstall the curl from macports and then run $ whereis curl which finds nothing.

So I go to the site suggested in the error message above. Most of the options don't seem applicable, but option 5 makes some sense:

Get a better/different/newer CA cert bundle! One option is to extract the one a recent Firefox browser uses by running 'make ca-bundle' in the curl build tree root

So I get the curl source code and run $ ./buildconf, $ ./configure, $ make, $ make ca-bundle, and finally $ sudo make install. I check $ whereis curl and it says "/usr/bin/curl".

But when I run the homebrew install command again (in a new terminal window), I get the same error shown above.

like image 992
Joshua Cheek Avatar asked Jul 03 '11 21:07

Joshua Cheek


1 Answers

You don't need to recompile cURL, it already has SSL/TLS support, otherwise, it wouldn't display error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed.

What you need is a bundle of CA certificates such as the server certificate of the server you're trying to talk to is issued by one of those CAs.

The cURL page you link from links to http://curl.haxx.se/docs/caextract.html

You should be able to download the combined PEM bundle and use it. You could force it using curl -fsSL --cacert /path/to/bundle.pem https://... in the command above, or use export CURL_CA_BUNDLE=/path/to/bundle.pem before running the command.

Normally, you'd need a way to trust what's inside this bundle, but there's always an element of "leap of faith" when it comes to importing commercial CAs (in the same way as they would be bundled for you with most browsers).

like image 95
Bruno Avatar answered Sep 25 '22 20:09

Bruno