Skip to content
ecdsa.com
Ruby openssl (Net::HTTP, Faraday, RubyGems)Ruby

Error message

state=error: certificate verify failed (certificate has expired)

Also printed as

  • OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 peeraddr=127.0.0.1:8443 state=error: certificate verify failed (certificate has expired)

Full message: "SSL_connect returned=1 errno=0 peeraddr=<ip>:<port> state=error: certificate verify failed (certificate has expired)". Certificates that are not valid yet produce "(certificate is not yet valid)".

Ruby openssl (Net::HTTP, Faraday, RubyGems) — OpenSSL::SSL::SSLError from SSL_connect

What it means

OpenSSL found a certificate in the chain whose validity period ended before the current time of the machine running Ruby. Most often the server's certificate was not renewed or the renewal was not deployed; on old systems an outdated CA bundle can make OpenSSL build the path through an expired root.

Why it happens

How to fix it

  1. 1.

    Check the served certificate's end date

    If it is in the past, renew; if it is fine, look at the client's bundle and clock.

    bash
    echo | openssl s_client -connect api.example.com:443 -servername api.example.com 2>/dev/null \
      | openssl x509 -noout -subject -enddate
  2. 2.

    Refresh the client's CA bundle

    Updating ca-certificates fixes clients that build paths through retired roots.

    bash
    # Old images: refresh the CA bundle Ruby's OpenSSL uses
    apt-get update && apt-get install --only-upgrade -y ca-certificates
    ruby -ropenssl -e 'p OpenSSL::X509::DEFAULT_CERT_FILE'
  3. 3.

    Renew and reload the server

    Renew the certificate and reload the TLS terminator; check the result from the network side.

    bash
    sudo certbot renew && sudo systemctl reload nginx

Related errors

Browse the full signature error database