python network_error ai_generated true

httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not trusted (_ssl.c:1123) while connecting to 'https://untrusted.example.com'

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2025-08-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

The server's certificate is signed by a CA that is not trusted by the system.

generic

中文

服务器的证书由系统不信任的CA签名。

Workarounds

  1. 90% success Properly install the CA certificate in the system trust store
    # On Windows: import the .crt file into 'Trusted Root Certification Authorities'
    # On macOS: sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ca.crt
  2. 85% success Use the verify parameter with the CA certificate file
    httpx.get('https://untrusted.example.com', verify='/path/to/ca.crt')

Dead Ends

Common approaches that don't work:

  1. Adding the certificate to the system trust store incorrectly 70% fail

    Improper installation may still not make it trusted.

  2. Using verify=False as a permanent solution 60% fail

    Disables security and is not recommended for production.