python network_error ai_generated true

httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123) while connecting to 'https://internal.example.com'

ID: python/httpx-connecterror-ssl-certificate-verify-failed

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2025-04-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

The server's certificate chain is incomplete or the CA certificate is not installed locally.

generic

中文

服务器的证书链不完整或本地未安装CA证书。

Workarounds

  1. 90% success Install the missing CA certificate in the system trust store
    # On Linux: sudo cp ca.crt /usr/local/share/ca-certificates/ && sudo update-ca-certificates
    # Then use httpx normally
  2. 85% success Provide the CA certificate file via the verify parameter
    httpx.get('https://internal.example.com', verify='/path/to/ca.crt')

Dead Ends

Common approaches that don't work:

  1. Disabling SSL verification entirely 70% fail

    Compromises security and does not address the missing CA.

  2. Using a different SSL library 90% fail

    The issue is with the certificate, not the library.