Could not find a valid gem: certificate verification failed

I am trying to install ssh tunnel on a remote server as described here: ssh from Heroku on a remote server with Mysql Db

But I hung up just trying to load the gems. I added:

# file: Gemfile ... gem 'net-ssh-gateway', '~> 1.2.0' 

but when I do bundle install (or even just gem install net-ssh on the command line), I get:

 ERROR: Could not find a valid gem 'net-ssh' (>= 0), here is why: Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/latest_specs.4.8.gz) 

According to the README for net-ssh ( https://github.com/net-ssh/net-ssh ), I checked my OpenSSL bindings for Ruby - they look good:

 $ ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION' OpenSSL 1.0.1j 15 Oct 2014 

I'm not sure if this is related, but when I tried to download the .pem file to download the high security gemfile:

 $ curl -O https://raw.github.com/net-ssh/net-ssh/master/gem-public_cert.pem 

... he did not download the .pem file, and visiting the URL directly leads to "not found".

Additional Information:

 $ rake about About your application environment Ruby version 2.1.4-p265 (x86_64-darwin14.0) RubyGems version 2.2.2 Rack version 1.5 Rails version 4.1.7 

So right now, I'm stuck. Does anyone know this problem?

+6
source share
3 answers

Despite @Tin Man's helpful answer, my problem was that I did not have certificates installed in the place where OpenSSL could find them.

The following recommendations in SSL Error Installing rubygems cannot retrieve data from https://rubygems.org/ :

Inadequate workaround

You can get around this by changing the first line of the Gemfile from

 source 'https://rubygems.org' 

to a form other than https:

 source 'http://rubygems.org' 

and then run the usual bundle install . After that, you must restore the first line of your Gemfile in order to use the https form. This is usually considered a security risk.

What else, you did not actually address the real problem that you lack valid certificates, and you run into problems if your application calls use OpenSSL (e.g. net-ssh).

Best fix

See SSL Error. Installing rubygems fails to extract data from https://rubygems.org/ . For OS X users, we ask Ruby to tell us where he is looking for the certificate file, and then use security find-certificate to populate the certificate file:

 $ cert_file=$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE') $ echo $cert_file $ security find-certificate -a -p /Library/Keychains/System.keychain > "$cert_file" $ security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> "$cert_file" 

After that, I was able to call bundle install without errors.

+6
source

This helped in my case when I had a problem with the certificate:

 gem sources -r https://rubygems.org gem sources -a http://rubygems.org gem update --system gem sources -r http://rubygems.org gem sources -a https://rubygems.org 
+12
source

Hi everyone, this link, so you don’t have to manually install it every time.

This suggests that the problem is related to changing rubygems ssl certasdaasdlashjd blah blah. The NVM link best explains: p

0
source

Source: https://habr.com/ru/post/979083/


All Articles