python network_error ai_generated true

requests.exceptions.SSLError: HTTPSConnectionPool(host='internal.example.com', port=443): 超过最大重试次数 (由SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:证书链中存在自签名证书'))引起)

requests.exceptions.SSLError: HTTPSConnectionPool(host='internal.example.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain')))

ID: python/requests-sslerror-self-signed-certificate

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
0证据数
2024-07-22首次发现

版本兼容性

版本状态引入弃用备注
3.x active

根因分析

服务器使用自签名证书,默认CA包不信任该证书。

English

The server uses a self-signed certificate that is not trusted by the default CA bundle.

generic

解决方案

  1. 90% 成功率 Provide the self-signed certificate file to verify parameter
    requests.get('https://internal.example.com', verify='/path/to/cert.pem')
  2. 85% 成功率 Use a custom CA bundle that includes the self-signed certificate
    requests.get('https://internal.example.com', verify='/path/to/custom-ca-bundle.crt')

无效尝试

常见但无效的做法:

  1. Setting verify=False globally 60% 失败

    Disables security checks, making the connection vulnerable to attacks.

  2. Adding the certificate to the system trust store without proper configuration 70% 失败

    The system trust store may not be used by Python's requests library by default.