security level SSL / TLS Origin: Network OSI layer 6 · Presentation Last updated 18 Nov 2026

Python/OpenSSL: SSLV3_ALERT_HANDSHAKE_FAILURE or CA_MD_TOO_WEAK — OpenSSL security level 2 rejects legacy servers

A modern Python/OpenSSL (Debian/Ubuntu security level 2) refuses weak keys, SHA-1 or small DH from an older server.

Exact message you may see [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure[SSL: DH_KEY_TOO_SMALL] dh key too small[SSL: CA_MD_TOO_WEAK] ca md too weakssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE]
Seen on: Python OpenSSL SSL

Meaning

Best fix is on the server (2048-bit keys, SHA-256, modern ciphers). For a trusted legacy endpoint only, lower the level in the context: ctx.set_ciphers("DEFAULT:@SECLEVEL=1"), or CipherString = DEFAULT@SECLEVEL=1 in openssl.cnf.

Common causes

  • Server with DH/RSA key under 2048 bits
  • SHA-1 signed certificate
  • RC4/3DES-only server
  • Distribution tightened defaults
  • OpenSSL 3 security level

⚡ Quick fix

  1. Upgrade the server's TLS parameters
  2. Scope @SECLEVEL=1 to that one connection
  3. Avoid lowering the system-wide level

Detailed fix by platform

Python

  1. python
    import ssl
    ctx = ssl.create_default_context()
    ctx.set_ciphers("DEFAULT:@SECLEVEL=1")   # trusted legacy server only

How to diagnose

  1. Server — Weak params?
  2. Level — Lowered scoped?
  3. Upgrade — Possible?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

ca md too weak / ee key too small — OpenSSL: error:0A00018E:SSL routines::ca md too weak / error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small (SSL / TLS)ca md too weak / ee k…certifi — requests SSLError: CERTIFICATE_VERIFY_FAILED because certifi is outdated (missing a new root CA) (SSL / TLS)certifiConnectionRefusedError [Errno 111] (SMTP) — Python: ConnectionRefusedError: [Errno 111] Connection refused — smtplib connect to localhost:25 (Email / SMTP)ConnectionRefusedErro…Django — Django send_mail: ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] (EMAIL_USE_SSL vs EMAIL_USE_TLS on the wrong port) (Email / SMTP)DjangoHeartbleed — Heartbleed (CVE-2014-0160): OpenSSL heartbeat extension vulnerable (SSL / TLS)HeartbleedHTTPSConnectionPool: Max retries exceeded (SSLError) — Python requests: HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /v1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] ...'))) (SSL / TLS)HTTPSConnectionPool: …macOS — Python on macOS: SSL: CERTIFICATE_VERIFY_FAILED unable to get local issuer certificate (run Install Certificates.command) (SSL / TLS)macOSopenssl.cnf — OpenSSL: Can't open openssl.cnf for reading / error loading config file (SSL / TLS)openssl.cnfsecurity …

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.