Ruby

bundle install fails with SSL certificate verification error

19 September 2026 · 10 min read

bundle install fails with SSL certificate verification error

Encountering a “bundle install fails with SSL certificate verification error” can be a frustrating roadblock for Ruby developers. This error, often cryptic and seemingly out of nowhere, prevents you from installing the necessary gems for your project. It’s a common issue, especially when working with Ruby on Rails projects that rely heavily on Bundler to manage dependencies. The error arises when Bundler, the gem dependency manager, can’t establish a secure connection with the RubyGems.org server due to problems with SSL certificate validation. This blog post will delve into the root causes of this error, provide step-by-step solutions, and equip you with the knowledge to prevent it from recurring, ensuring a smoother and more productive development experience. We’ll cover common causes like outdated certificates, proxy issues, and incorrect Ruby versions, offering practical fixes for each scenario.

Understanding the SSL Certificate Verification Error

The “SSL certificate verification error” during a bundle install process essentially means your system doesn’t trust the SSL certificate presented by the RubyGems server. SSL (Secure Sockets Layer) certificates are digital certificates that verify the identity of a website and encrypt communication between the server and your browser (or in this case, Bundler). When the verification fails, it indicates a problem with either the certificate itself, your system’s ability to validate the certificate, or a configuration issue that’s interfering with the validation process. This could be due to an outdated certificate authority (CA) bundle on your machine, a proxy server interfering with the connection, or even a misconfigured Ruby environment.

Several factors can contribute to this issue. Your system’s list of trusted certificate authorities might be outdated, preventing it from recognizing the RubyGems.org certificate. Corporate networks often employ proxy servers that intercept and re-sign SSL certificates, which your system might not be configured to trust. Furthermore, specific versions of Ruby or Bundler might have compatibility issues or bugs related to SSL certificate handling. According to a Stack Overflow survey, SSL certificate issues are among the most frequently encountered problems when setting up Ruby development environments. Stack Overflow is a useful resource for debugging.

Identifying the root cause is crucial for implementing the correct solution. Before diving into specific fixes, consider whether you’ve recently updated your system, changed network settings, or upgraded your Ruby environment. These changes often trigger SSL certificate verification problems. Keep in mind that neglecting this issue can lead to significant delays in your development workflow, as you won’t be able to install or update gem dependencies. The featured snippet below provides a summary of a common solution:

To resolve SSL certificate verification errors during bundle install, a common solution is to update your system’s certificate authority (CA) bundle. This bundle contains a list of trusted certificate authorities. Outdated bundles can prevent your system from recognizing valid SSL certificates, leading to the error. You can update the CA bundle using your operating system’s package manager or by manually downloading the latest bundle from a trusted source and configuring Ruby to use it.

Common Causes and Solutions

Several factors can lead to SSL certificate verification issues during bundle install. Addressing these common causes systematically can often resolve the problem quickly.

  • Outdated Certificate Authority (CA) Bundle: Your system’s list of trusted certificate authorities might be stale, preventing it from recognizing the RubyGems.org certificate.
  • Proxy Server Interference: Corporate networks often use proxy servers that intercept and re-sign SSL certificates, which your system might not be configured to trust.
  • Incorrect Ruby Version: Certain Ruby versions might have compatibility issues or bugs related to SSL certificate handling.

Let’s explore some solutions:

Updating the Certificate Authority (CA) Bundle

The most common solution involves updating your system’s CA bundle. This bundle contains a list of trusted certificate authorities. Here’s how to update it on different operating systems:

  1. macOS: Use brew install openssl and then set the SSL_CERT_FILE environment variable to point to the OpenSSL certificate file. For example, export SSL_CERT_FILE=/usr/local/etc/openssl@1.1/cert.pem. You may also need to update your Ruby version using a tool like rbenv or rvm after updating OpenSSL.
  2. Linux (Debian/Ubuntu): Run sudo apt-get update && sudo apt-get install ca-certificates. This command updates the system’s certificate store with the latest certificates.
  3. Windows: Download the latest CA bundle from a trusted source like cURL’s website and set the SSL_CERT_FILE environment variable to point to the downloaded file.

After updating the CA bundle, try running bundle install again. If the error persists, proceed to the next solution.

Configuring Bundler to Trust the Certificate

Sometimes, Bundler itself needs to be explicitly configured to trust the SSL certificate. This can be achieved by modifying Bundler’s configuration:

Run the following command in your terminal: bundle config set ssl_verify_mode 0. This command disables SSL verification for Bundler. While this might seem like a less secure option, it can be useful as a temporary workaround, especially in environments where updating the CA bundle is not feasible. However, it’s generally recommended to address the underlying certificate issue rather than permanently disabling SSL verification. Ensure you understand the security implications before disabling SSL verification. Consider this a temporary fix while you resolve the root cause of the SSL issue.

Addressing Proxy Server Issues

If you’re behind a proxy server, you need to configure Bundler to use the proxy. You can do this by setting the http_proxy and https_proxy environment variables:

export http_proxy=http://your_proxy_address:your_proxy_port
export https_proxy=http://your_proxy_address:your_proxy_port

Replace your_proxy_address and your_proxy_port with the actual address and port of your proxy server. If your proxy requires authentication, include the username and password in the proxy URL: http://username:password@your_proxy_address:your_proxy_port. Once you’ve set these environment variables, try running bundle install again. If you continue to experience issues, check your proxy settings with your network administrator to ensure they are correct. Properly configuring your proxy settings is crucial for establishing a secure connection and resolving SSL certificate verification errors.

Advanced Troubleshooting Techniques

If the previous solutions haven’t resolved the issue, more advanced troubleshooting might be necessary. This could involve inspecting the SSL certificate itself, checking your Ruby version, or examining Bundler’s configuration files.

First, inspect the SSL certificate presented by RubyGems.org. You can do this using the openssl command-line tool. Run the following command: openssl s_client -showcerts -connect rubygems.org:443. This command displays the SSL certificate chain. Examine the output for any errors or warnings, such as expired certificates or untrusted certificate authorities. The output can provide valuable clues about the specific certificate issue you’re encountering. For example, it might reveal that the certificate is issued by an unknown or untrusted CA.

Next, verify your Ruby version. Older Ruby versions might have known issues with SSL certificate handling. Consider upgrading to a more recent, stable Ruby version using a tool like rbenv or rvm. Before upgrading, back up your existing Ruby environment to avoid any data loss. After upgrading, ensure that Bundler is compatible with the new Ruby version. You can update Bundler by running gem install bundler. Bundler’s official website provides detailed information about compatibility and installation.

Finally, examine Bundler’s configuration files. Bundler stores its configuration in a file called .bundle/config in your project directory. Check this file for any settings that might be interfering with SSL certificate verification. In particular, look for settings related to SSL verification or proxy servers. If you find any suspicious settings, try removing them or modifying them to see if they resolve the issue. Be cautious when modifying Bundler’s configuration files, as incorrect settings can lead to unexpected behavior.

Infographic here
Preventing Future SSL Certificate Issues ----------------------------------------

While resolving the immediate error is important, preventing future occurrences is even more valuable. Proactive measures can significantly reduce the likelihood of encountering SSL certificate verification issues during bundle install.

  • Keep Your System Updated: Regularly update your operating system and installed software, including Ruby and Bundler.
  • Use a Ruby Version Manager: Use a tool like rbenv or rvm to manage multiple Ruby versions and keep them up-to-date.
  • Stay Informed: Subscribe to security advisories and mailing lists related to Ruby and Bundler to stay informed about potential SSL certificate issues.

One key practice is to regularly update your system’s CA bundle. Most operating systems provide automated mechanisms for updating the CA bundle. Ensure that these mechanisms are enabled and functioning correctly. For example, on Debian/Ubuntu systems, the ca-certificates package is responsible for managing the CA bundle. Periodically running sudo apt-get update && sudo apt-get upgrade ca-certificates ensures that your system has the latest trusted certificates. Keeping your system updated is a fundamental step in preventing SSL certificate verification errors.

Another important step is to use a Ruby version manager like rbenv or rvm. These tools allow you to manage multiple Ruby versions on your system and easily switch between them. Using a Ruby version manager ensures that you’re always using a supported and up-to-date Ruby version, which reduces the risk of encountering SSL certificate issues. Furthermore, Ruby version managers often provide mechanisms for managing gemsets and dependencies, which can help prevent conflicts and ensure a consistent development environment. Using a version manager makes it easy to upgrade your Ruby version when necessary and test your code against different Ruby versions.

Finally, stay informed about potential SSL certificate issues. Subscribe to security advisories and mailing lists related to Ruby and Bundler. These resources often provide early warnings about potential SSL certificate problems and offer guidance on how to mitigate them. Being proactive and staying informed can help you prevent SSL certificate verification errors before they impact your development workflow. Consider following relevant blogs and forums to stay up-to-date on the latest security best practices.

FAQ: Addressing Common Questions

Why am I getting an SSL certificate verification error?
This error typically occurs because your system doesn't trust the SSL certificate presented by the RubyGems server. This can be due to an outdated CA bundle, proxy server interference, or an incompatible Ruby version.
How do I update my CA bundle?
The process varies depending on your operating system. On macOS, you can use `brew install openssl`. On Linux (Debian/Ubuntu), use `sudo apt-get update && sudo apt-get install ca-certificates`. On Windows, download the latest CA bundle from a trusted source and set the `SSL_CERT_FILE` environment variable.
What if I'm behind a proxy server?
You need to configure Bundler to use the proxy by setting the `http_proxy` and `https_proxy` environment variables. For example: `export http_proxy=http://your_proxy_address:your_proxy_port`.
Is it safe to disable SSL verification?
Disabling SSL verification (`bundle config set ssl_verify_mode 0`) should only be used as a temporary workaround. It's generally recommended to address the underlying certificate issue rather than permanently disabling SSL verification.
Experiencing a "bundle install fails with SSL certificate verification error" can be a significant hurdle, but by understanding the underlying causes and applying the solutions outlined in this guide, you can overcome this challenge and ensure a smooth development workflow. Remember to prioritize updating your CA bundle, configuring your proxy settings correctly, and keeping your Ruby environment up-to-date. By taking these proactive measures, you can significantly reduce the likelihood of encountering SSL certificate issues in the future. Don't let SSL errors slow you down; take control of your development environment and keep your projects moving forward. Explore related topics like Ruby gem management and secure coding practices to further enhance your development skills. Consider reading about common Ruby on Rails security vulnerabilities to broaden your knowledge. [Learn more about Ruby and Rails.](https://courthousezoological.com/n7sqp6kh?key=e6dd02bc5dbf461b97a9da08df84d31c)**Question & Answer :** When I run `bundle install` for my Rails 3 project on Centos 5.5 it fails with an error:
Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://bb-m.rubygems.org/gems/multi_json-1.3.2.gem) An error occured while installing multi_json (1.3.2), and Bundler cannot continue. Make sure that `gem install multi_json -v '1.3.2'` succeeds before bundling. 

When I try to install the gem manually (by gem install multi_json -v '1.3.2') it works. The same problem occurs with several other gems. I use RVM (1.12.3), ruby 1.9.2, bundler 1.1.3.

How to fix it?

Update

Now that I’ve karma wh..err mined enough from this answer everyone should know that this should have been fixed.

re: via Ownatik again bundle install fails with SSL certificate verification error

gem update --system 

My answer is still correct and left below for reference if that ends up not working for you.


Honestly the best temporary solution is to

[…] use the non-ssl version of rubygems in your gemfile as a temporary workaround.

via user Ownatik

what they mean is at the top of the Gemfile in your rails application directory change

source 'https://rubygems.org'

to

source 'http://rubygems.org'

note that the second version is http instead of https