Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL verification error when installing cocoapods

What I did sudo gem install cocoapods

This is the full message from terminal

ERROR:  You must add /C=BE/O=GlobalSign nv-sa/CN=AlphaSSL CA - SHA256 - G2 to your local trusted store
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - hostname "rubygems.org" does not match the server certificate (https://rubygems.org/specs.4.8.gz)
ERROR:  SSL verification error at depth 0: unable to get local issuer certificate (20)

I have no experience with SSL but I followed a couple of question similar to mine but no luck

What I've tried:

  • Download and install the new SHA256 intermediate certificate
  • Change hostname from https to http
  • Follow this guide but couldn't copy GlobalSignRootCA.pem to ruby folder
  • Use HomeBrew but got another error while installing it
like image 625
bao le Avatar asked Jan 23 '26 12:01

bao le


1 Answers

MichaelHuelsen has the correct answer. Here I will give my step-by-step instructions that worked for me but overwrites the pem file with a large one, so beware if this has sensitive info you might want to not destroy.

  1. ID the cert file.
$ ruby -ropenssl -e 'p OpenSSL::X509::DEFAULT_CERT_FILE'
"/etc/pki/tls/cert.pem"

Tells me where my cert file is.

  1. Backup the cert file
cp /etc/pki/tls/cert.pem /tmp/cert.pem.bak
  1. Copy down a full cert file via curl

See: https://curl.se/docs/caextract.html

curl --remote-name --time-cond cacert.pem https://curl.se/ca/cacert.pem
  1. Move the new cacert.pem file to replace the old one
mv cacert.pem /etc/pki/tls/cert.pem

I then ran gem update --system to update things, but you may just be ok running your original gem command.

like image 154
mpettis Avatar answered Jan 25 '26 08:01

mpettis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!