ruby-on-railssslopensslcertificaterails-assets

Could not verify the SSL certificate error when running bundle install in ruby on rails app


I have a ruby on rails app that is throwing an error when I try to run bundle install. The error is the following:

bundle stdout: Could not verify the SSL certificate for https://rails-assets.org/ There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification

Our SSL certificate was updated just a few days ago and we haven't changed anything in the app. It started to throw this error out of the blue.

Is there any chance we need to update the root certificates in the system? I mean like running sudo update-ca-certificates or something like that? is it safe to do that?

The app is in digitalOcean and we use capistrano gem to deploy the app

@lingYan Thanks a lot for guiding me in the right direction! I read the links you posted but in my case I had to change the steps a little bit because I am not on Centos-7. So this is exactly what I did:

It was still throwing the error after doing all the steps above so I realized that I didn't have the ISRG Root CA certificate. In order to add the ISRG Root CA I did the following (which I think it is not correct or maybe I am missing something):

Am I doing someting wrong? Are the steps above correct to add a new certificate? I am starting to feel frustrated with this :(


Solution

  • I checked the certificate of https://rails-assets.org/, it's signed by LetsEncrypt and one of the Root CA from LetsEncrypt is expired and that would be the cause of your issue.

    To understand the issue:

    https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/

    The possible solution: https://blog.devgenius.io/rhel-centos-7-fix-for-lets-encrypt-change-8af2de587fe4

    Basically, if that's the cause, you need to remove the DST Root CA and make sure ISRG Root CA is in your certificate store.

    For ubuntu or Debian system, the following document describes how to update the certificates: /usr/share/doc/ca-certificates/README.Debian

    1. Run the following command to create a directory for your own trusted ca-certificates: sudo mkdir /usr/local/share/ca-certificates/extra
    2. Copy the root certificate to the new directory: sudo cp rootCA.crt /usr/local/share/ca-certificates/extra/ Make sure that the certificate file has the .crt extension.
    3. Run the following command to update the system certificates: sudo update-ca-certificates