OpenSSL::SSL::SSLError SSL_connect returned=1 errno=0 state=error: certificate verify failed
Let's Encrypt certificates may be affected by the recent expiry (2021-09-30) of their old root certificate. https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/
Requirements:
- all clients of your API must trust ISRG Root X1 (not just DST Root CA X3), and
- if clients of your API are using OpenSSL, they must use version 1.1.0 or later.
You may need to upgrade OS and OpenSSL on your CI machine.
Here is a list of compatible OS: https://letsencrypt.org/docs/certificate-compatibility/
Upgrade your openssl version >= 1.1.0 and OS.
If you are still seeing issues then most likely your application is configured to not use operating system certificates. For instance you use certified gem. See comments to this gist.
The other most likely issue could be a change on your CI server. For instance, if you use Docker then maybe something changed in the Docker image or one of its layers and you might use an outdated openssl
library. Or you use old Ruby version that depends on the old OpenSSL system library?
You can run the following code to check what TLS version is used in your project.
Please ensure you run the code in the rails environment on your CI. You can do this either through rails console, or by running a script using rails runner
require 'net/https'
require 'json'
uri = URI("https://www.howsmyssl.com/")
http = ::Net::HTTP.new uri.host, uri.port
http.use_ssl = true
data = JSON.parse(http.get('/a/check').body)
puts "TLS Version Negotiated: #{data['tls_version']}"
puts "Open SSL version: #{OpenSSL::OPENSSL_VERSION}"
In my case it prints code: TLS Version Negotiated: TLS 1.3
Another thing you can check is openssl version: OpenSSL::OPENSSL_VERSION
knapsack_pro gem
uses Net::HTTP from Ruby standard library to make requests. This depends on OpenSSL library in OS.
https://github.com/KnapsackPro/knapsack_pro-ruby/blob/e0b9baea5a5c3c4f65e924fac5d9dddac9f2f711/lib/knapsack_pro/client/connection.rb#L145
So it's the error on openssl/ruby level and we can't change OpenSSL version in your OS from knapsack_pro gem level.
Most likely you need to update openssl in CI server so that Ruby uses the proper openssl library and you need to update your operating system in order to trust ISRG Root X1.
If you use Debian on CI, you may want to update docker image to a newer version or you could use Ubuntu to use proper OpenSSL version.