63

I tried to install cocoapods (http://cocoapods.org/) on my OSX Mountain Lion.

 moshe-mbp:~ moshem$ gem install cocoapods
 ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
      Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0      state=SSLv3 read server key exchange B: bad ecpoint (https://rubygems.org/latest_specs.4.8.gz)

first I tried

 rvm reinstall all --force

then I tried

 brew upgrade openssl

    ==> Upgrading openssl
    ==> Downloading http://openssl.org/source/openssl-1.0.1e.tar.gz
    Already downloaded: /Library/Caches/Homebrew/openssl-1.0.1e.tar.gz
    ==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.1e --openssldir=/usr/local/etc/openssl zlib-dynamic shared d
    ==> make
    ==> make test
    ==> make install MANDIR=/usr/local/Cellar/openssl/1.0.1e/share/man MANSUFFIX=ssl
    ==> Caveats
    To install updated CA certs from Mozilla.org:

        brew install curl-ca-bundle

    This formula is keg-only: so it was not symlinked into /usr/local.

    Mac OS X already provides this software and installing another version in
    parallel can cause all kinds of trouble.

    The OpenSSL provided by OS X is too old for some software.

    Generally there are no consequences of this for you. If you build your
    own software and it requires this formula, you'll need to add to your
    build variables:

        LDFLAGS:  -L/usr/local/opt/openssl/lib
        CPPFLAGS: -I/usr/local/opt/openssl/include

    ==> Summary
      /usr/local/Cellar/openssl/1.0.1e: 429 files, 15M, built in 5.1 minutes

I then tried

openssl version

and still(!) gets the older version

moshe-mbp:~ moshem$ openssl version
OpenSSL 0.9.8r 8 Feb 2011
moshe-mbp:~ moshem$ 

what am I doing wrong? how can I install the cocoapods gem?

thanks


EDIT, trying @sean suggestion:

moshe-mbp:~ moshem$ brew update
Updated Homebrew from 672af665 to 10b4d426.
==> Updated Formulae
bash        wireshark
moshe-mbp:~ moshem$ brew install openssl
Error: openssl-1.0.1e already installed
moshe-mbp:~ moshem$ brew link openssl --force
Linking /usr/local/Cellar/openssl/1.0.1e... 1139 symlinks created
moshe-mbp:~ moshem$ brew install curl-ca-bundle
Error: curl-ca-bundle-1.87 already installed
moshe-mbp:~ moshem$ 
moshe-mbp:~ moshem$ openssl version
OpenSSL 0.9.8r 8 Feb 2011
moshe-mbp:~ moshem$ gem install cocoapods
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint (https://rubygems.org/latest_specs.4.8.gz)

EDIT (2) after fixing issues with brew doctor

moshe-mbp:~ moshem$ gem install cocoapods
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint (https://rubygems.org/latest_specs.4.8.gz)
moshe-mbp:~ moshem$ openssl version
OpenSSL 0.9.8r 8 Feb 2011
moshe-mbp:~ moshem$ brew update
Updated Homebrew from 10b4d426 to 6a00bc3c.
==> Updated Formulae
clozure-cl  python  python3
moshe-mbp:~ moshem$ brew install openssl
Error: openssl-1.0.1e already installed
moshe-mbp:~ moshem$ 
moshe-mbp:~ moshem$ echo $PATH
/Users/moshem/.rvm/gems/ruby-2.0.0-p0/bin:/Users/moshem/.rvm/gems/ruby-2.0.0-p0@global/bin:/Users/moshem/.rvm/rubies/ruby-2.0.0-p0/bin:/Users/moshem/.rvm/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/tools:/platforms:/platform-tools:
moshe-mbp:~ moshem$ 

EDIT after altering the /etc/paths

I edited the /etc/path files to:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

closed terminal completly and reopend and it still launches the old version of openssl!

why?

moshe-mbp:~ moshem$ env $PATH
env: /Users/moshem/.rvm/gems/ruby-2.0.0-p0/bin:/Users/moshem/.rvm/gems/ruby-2.0.0-p0@global/bin:/Users/moshem/.rvm/rubies/ruby-2.0.0-p0/bin:/Users/moshem/.rvm/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/tools:/platforms:/platform-tools

EDIT, my bash_profile

source "`brew --prefix grc`/etc/grc.bashrc"

export PATH=${JAVA_HOME}/bin:$PATH
export PATH="$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platforms:$ANDROID_SDK/platform-tools:$ANDROID_NDK"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

BTW, the /etc/grc.bashrc doesn't seem to exist on my machine. both this line and the rvm line at the end were added by installed scripts


EDIT

moshe-mbp:~ moshem$ rvm pkg install openssl 
Fetching openssl-1.0.1c.tar.gz to /Users/moshem/.rvm/archives
Extracting openssl to /Users/moshem/.rvm/src/openssl-1.0.1c
Configuring openssl in /Users/moshem/.rvm/src/openssl-1.0.1c.
Compiling openssl in /Users/moshem/.rvm/src/openssl-1.0.1c.
Installing openssl to /Users/moshem/.rvm/usr

Please note that it's required to reinstall all rubies:

    rvm reinstall all --force

Updating openssl certificates
moshe-mbp:~ moshem$ openssl version
OpenSSL 1.0.1e 11 Feb 2013


moshe-mbp:~ moshem$ gem source -r http://rubygems.org/
http://rubygems.org/ removed from sources
moshe-mbp:~ moshem$ gem source -a https://rubygems.org/
Error fetching https://rubygems.org/:
    SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint (https://rubygems.org/specs.4.8.gz)
moshe-mbp:~ moshem$ gem install cocoapods
ERROR:  Could not find a valid gem 'cocoapods' (>= 0) in any repository
Moshe Marciano
  • 2,349
  • 4
  • 33
  • 44

11 Answers11

78

This is fixed by avoiding https and using the insecure http instead. Running this worked for me.

gem source -a http://rubygems.org/
Ackshaey Singh
  • 863
  • 10
  • 5
55
rvm osx-ssl-certs update all

did the trick for me, ruby 2.0.0

antpaw
  • 15,444
  • 11
  • 59
  • 88
  • 3
    For some reason my permissions were incorrect on /etc/openssl. Fix: sudo chmod og+rw /etc/openssl. (then run the above command for the actual fix if you had permission issues as I did). This comment is for other people, not the author of this answer. – Joe Johnson Nov 01 '13 at 23:37
  • What the heck? I've got Ruby 2.3 and I get this `rvm osx-ssl-certs update all *** ERROR Unknown command line option: "osx-ssl-certs"` – kayleeFrye_onDeck Jun 25 '16 at 01:33
39

Try using http://rubygems.org/ (without SSL) as a source — that fixed the error for me.

gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
gem install cocoapods
Ernests Karlsons
  • 2,220
  • 5
  • 25
  • 37
  • 2
    this works... THANK YOU! but I feel like I am cheating, because I still have a broken openSSL installation and it might break other stuff on my machine.. – Moshe Marciano Mar 11 '13 at 17:52
  • 2
    This answer is slightly better than the accepted one, because it includes the step of removing the secure source. When I tried using the accepted answer, simply adding the unsecure source, the install command still failed with the original error, because the secure source was still in the list of sources and it was used first. – Mr. Lance E Sloan Jan 14 '15 at 14:51
  • 2 years old, but worked like a charm except I needed "sudo gem install cocoapods" :) – Erik Bean Dec 28 '15 at 22:58
  • 1
    can't run `$ gemsource`. says openssl could not be loaded – Daniel Lizik Jan 06 '20 at 06:52
26

Current release of rvm does a lot better job handling this things, run:

rvm get head
rvm reload
rvm autolibs enable
rvm reinstall 1.9.3 --disable-binary

Make sure to follow any displayed instructions - it's all there to help you.

mpapis
  • 52,729
  • 14
  • 121
  • 158
11

I had the same error. To fix just run the following commands (I know you've ran some but humor me):

brew update
brew install openssl
brew link openssl --force
brew install curl-ca-bundle

After that, open a new shell or source your files and all should be good to go :)

UPDATE:

To update your paths you'll need to edit your /etc/paths file so do something like:

sudo vim /etc/paths

In there is should look something like:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

What you want to do is to ensure that /usr/local/bin is at the top of the file. So change it to something like:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

Hope that fixes it!

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Sean
  • 2,891
  • 3
  • 29
  • 39
  • done, but it is the same, I updated the original question with this attempt result – Moshe Marciano Mar 09 '13 at 06:46
  • And you tried opening a new shell window with the same result? It might also be a problem with your paths. Does brew doctor give you any advice? – Sean Mar 09 '13 at 15:21
  • brew doctor was nice, did not know about it, run and made the adjustments suggested. then tried again and it again used the old one. I updated my original question with this and the current PATH – Moshe Marciano Mar 09 '13 at 16:22
  • it seems that it is taking the old one from /usr/bin/openssl, can you tell me what needs to be done to make that path point to the new one? – Moshe Marciano Mar 10 '13 at 10:57
  • I updated my answer with how you change your path. Hopefully this finally gets it! – Sean Mar 11 '13 at 02:00
  • just tried it, it was indeed the other way around, but after changing it it still doesn't work! I updated my question with the results of it – Moshe Marciano Mar 11 '13 at 06:39
  • I'm pretty stumped. One last thing to try: 'brew tap raggi/ale' then 'brew install openssl-osx-ca' – Sean Mar 11 '13 at 07:04
  • Perhaps you have something in your shell/profile that is forcing it to look at /usr/bin first? If you have a second shell on your system, try jumping to it and seeing if your openssl version is the same on it? I'm nearly out of ideas :) – Sean Mar 11 '13 at 07:16
  • Hi Sean, no second shell, just plain bash, I tried the brew commands but it said "already done that". I will update my question with my ./bash_profile – Moshe Marciano Mar 11 '13 at 09:31
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/25945/discussion-between-moshe-marciano-and-sean) – Moshe Marciano Mar 11 '13 at 10:14
  • I was having a similar problem after migrating data from one macbook to another. I could run rails commands or bundler commands. I ran the first 2 lines: `brew update` and `brew install openssl` and that fixed it for me. bundler and rails commands are working – Cruz Nunez May 01 '19 at 16:22
10

UPDATE 2021-05-20: Rubygems changed the certificate they use. I've updated the link to the certificate but I have not confirmed this solution actually still works.

This is what solved it for me: Install this certificate: https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem

https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem

In this folder: {rubyfolder}\lib\ruby\x.x.x\rubygems\ssl_certs

This way you don't have to add insecure sources.

More info here: https://gist.github.com/luislavena/f064211759ee0f806c88 https://www.develves.net/blogs/asd/2016-04-08-rubygems-and-ssl/

gijswijs
  • 1,958
  • 19
  • 24
5

If you are in China, try using http://ruby.taobao.org/ as a source — that fixed the error for me. At the same time,avoid https. Running this worked for me.

gem sources --remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/
gem install cocoapods
ChenYilong
  • 8,543
  • 9
  • 56
  • 84
4

The following got everything working for me!

rvm get stable

brew update

brew install libyaml
brew install pkg-config 
brew install libxml2 
brew install libxslt

brew install openssl
brew link openssl --force

brew install sqlite

brew install apple-gcc42

rvm install 2.0.0 --with-gcc=gcc-4.2

If this doesn't work, remove your existing rubygems and follow this:

rvm remove 2.0.0
rvm get head --autolibs=3
rvm requirements

#At this point, brew install anything that's missing, like apple-gcc42.

rvm install 2.0.0 --with-gcc=gcc-4.2
Scotty
  • 2,635
  • 6
  • 30
  • 39
  • that did it THANK YOU, but now I tried to return to the https gem source to utilize my updated openssl. but it wont accept that, see bottom of my question for the terminal output – Moshe Marciano Mar 11 '13 at 21:37
  • Ah okay let's start again. Check my updated answer. I had the same issues as you with the openssl certificates, and doing the steps i mentioned sorted it. So i'm not sure what else to suggest if this doesn't work :/ Test this with new terminal windows too. – Scotty Mar 12 '13 at 13:46
  • Hey Scotty, I followed your instruction, but the install failed, see here https://gist.github.com/moshem/5147971 – Moshe Marciano Mar 12 '13 at 23:14
  • Interesting. What happens when you run it with `rvm get stable`? – Scotty Mar 13 '13 at 12:16
  • `rvm pkg install openssl` then `rvm requirements` make sure nothing's required. Then `rvm install 2.0.0 --with-gcc=gcc-4.2` – Scotty Mar 15 '13 at 20:18
  • well...that got us one step further, but still install fails... see here: https://gist.github.com/moshem/5180485 – Moshe Marciano Mar 17 '13 at 07:22
  • can you provide the next step? – Moshe Marciano Mar 21 '13 at 21:01
2

You can first install a newer openssl, as Mike Slutsky described. To check your openssl version:

$ openssl version

Get a more recent one here: http://www.openssl.org/source/ Then configure and install it:

$ cd openssl-1.0.1f_src/
$ ./Configure --prefix=/Users/me/bin/openssl-1.0.1f_bin darwin64-x86_64-cc
$ make install

Now configure ruby with this openssl:

$ cd ruby-2.1.0_src/
$ ./configure --with-openssl-dir=/Users/me/bin/openssl-1.0.1f_bin --prefix=/Users/me/bin/ruby-2.1.0_bin

Note: the new openssl does not need to be on you $PATH. This worked for me with ruby 2.0 and 2.1. Good luck (-:

1

You can try to update OpenSSL from source instead:

curl -L -O http://www.openssl.org/source/openssl-1.0.1b.tar.gz.asc
curl -L -O http://www.openssl.org/source/openssl-1.0.1b.tar.gz
gpg --verify openssl-1.0.1b.tar.gz.asc
tar xvzf openssl-1.0.1b.tar.gz
cd openssl-1.0.1b
perl ./Configure shared zlib --prefix=/opt/local darwin64-x86_64-cc
make
make test
sudo make install

source

Mike S
  • 11,329
  • 6
  • 41
  • 76
0

I fixed it by only appending to the PATH variable in my ~/.bash_profile, which in my case meant changing

export PATH="/usr/local/mysql/bin:$PATH"
export PATH=$M2:$PATH
export PATH=$JAVA_HOME/bin:$PATH

to

export PATH="$PATH:/usr/local/mysql/bin"
export PATH=$PATH:$M2
export PATH=$PATH:$JAVA_HOME/bin

In terminal, type nano ~/.bash_profile to start editing.

BrianHenryIE
  • 520
  • 5
  • 12