Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
Bug report
Bug description:
import requests
requests.get('https://www.google.com')urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Missing Authority Key Identifier (_ssl.c:1032)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/requests/adapters.py", line 644, in send
resp = conn.urlopen(
method=request.method,
...<9 lines>...
chunked=chunked,
)
File "/usr/local/lib/python3.13/site-packages/urllib3/connectionpool.py", line 841, in urlopen
retries = retries.increment(
method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
)
File "/usr/local/lib/python3.13/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Missing Authority Key Identifier (_ssl.c:1032)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
requests.get('https://www.google.com')
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "/usr/local/lib/python3.13/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.13/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.13/site-packages/requests/adapters.py", line 675, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Missing Authority Key Identifier (_ssl.c:1032)')))
The Linux machine is behind a corporate HTTP proxy with self-signed certificates.
The required Root CA Certificate has been added to the trust store, e.g. uploaded to /usr/local/share/ca-certificates followed by executing update-ca-certificates.
Furthermore the following environment variables are set:
ftp_proxy="ftp://<ftp-proxy-adress>:<ftp-proxy-port>/"
FTP_PROXY="ftp://<ftp-proxy-adress>:<ftp-proxy-port>/"
http_proxy="http://<http-proxy-adress>:<http-proxy-port>/"
HTTP_PROXY="http://<http-proxy-adress>:<http-proxy-port>/"
https_proxy="http://<http-proxy-adress>:<http-proxy-port>/"
HTTPS_PROXY="http://<http-proxy-adress>:<http-proxy-port>/"
no_proxy="127.0.0.1,localhost[,REDACTED]"
NO_PROXY="127.0.0.1,localhost[,REDACTED]"
CURL_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt"
REQUESTS_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt"
SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
ℹ️ This setup works fine for Python 3.12 (using pip, urllib3, requests, etc.) but not for Python 3.13 (using pip it works, though).
The Root CA Certificate contains the following lines:
Certificate:
Data:
....
X509v3 extensions:
...
X509v3 Basic Constraints: critical
CA:TRUE, pathlen:1
X509v3 Subject Key Identifier:
4E:32:71:1C:07:BB:1D:A8:A4:8A:F8:17:4B:B6:15:47:65:54:24:7E
X509v3 Authority Key Identifier:
4E:32:71:1C:07:BB:1D:A8:A4:8A:F8:17:4B:B6:15:47:65:54:24:7E
...
Is this, i.e. an AKI that matches the SKI, leading to the error?
- If yes: Is this considered a malformation?
- If yes: By CPython only or in general?
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Activity
benz0li commentedon Aug 27, 2025
P.S: Everything works fine with intranet pages that use a Root CA Certificate that contains the
X509v3 Subject Key Identifierline but not theX509v3 Authority Key Identifierline.StanFromIreland commentedon Aug 27, 2025
requests is not part of the stdlib, I suggest you open the issue in their tracker.
benz0li commentedon Aug 27, 2025
Is there a way to test this with stdlib only? In case this is related to
ssl.create_default_context(): addVERIFY_X509_STRICTandVERIFY_X509_PARTIAL_CHAINto the defaultverify_flags#107361– which I am quite sure of – and thus caused by ssl (part of the Python Standard Library).
benz0li commentedon Aug 27, 2025
Similar issue:
ZeroIntensity commentedon Aug 27, 2025
Please check if the C script I posted there reproduces with whatever site you're using. If anything, this is probably an issue with OpenSSL.
benz0li commentedon Aug 27, 2025
Using
curlas a reference for the same request on the same machine:benz0li commentedon Aug 27, 2025
Happy to do so.
I copied to
test.cand tried compiling (cc test.c):Anything I am missing? I am not familiar with C.
ZeroIntensity commentedon Aug 27, 2025
You need to link OpenSSL. Off the top of my head, it's
-lsslin GCC.benz0li commentedon Aug 27, 2025
Using
cc test.c -lssl -lcryptocompilation succeeded. Executing./a.outresults inafter some time.
@ZeroIntensity Please extend your C script so it respects proxy settings/'environment variables'.
Thank you.
benz0li commentedon Aug 27, 2025
And no, this is not an OpenSSL issue.
Tested using
opensslitself for the same request on the same machine:benz0li commentedon Aug 27, 2025
I suspect the issue being caused by the following:
benz0li commentedon Aug 27, 2025
– PKI team
– Copilot
Footnotes
https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.1 ↩
benz0li commentedon Aug 28, 2025
Any update on this?
23 remaining items
benz0li commentedon Aug 29, 2025
The build fails for 42974c4, 357bed0, 2c4e29e and 500b0f4.
As already mentioned, e295d86 works.
Also: #138193 (comment)
StanFromIreland commentedon Aug 29, 2025
Please don't copy the same message again, it just makes the thread confusing, and unnecessarily long.
ZeroIntensity commentedon Aug 29, 2025
I'm lost at this point. There's not really any way that the version bump could be the regressing commit. I guess you could try reverting smaller parts of the version bump to see if any single change to a file causes the regression?
StanFromIreland commentedon Aug 29, 2025
Maybe there is some gated code (depending on the version) in
requestscausing the error?benz0li commentedon Aug 29, 2025
Highly likely.
I tested with stdlib's
http.clientand everything seems fine:Seems to be an
urllib3issue. I will open an issue at https://github.com/urllib3/urllib3.ZeroIntensity commentedon Aug 29, 2025
It would make more sense for it to be a urllib3 issue, but also quite confusing. Since it reproduces when 3.13 was equivalent to 3.12b1, there would have to be a 3.13 gate for a <3.12 feature. Not impossible, but certainly not common.
benz0li commentedon Aug 30, 2025
In urllib3, it triggers for
sys.version_info >= (3, 13).Cross reference:
benz0li commentedon Aug 30, 2025
#138193 (comment) is wrong. I should have tested with a Python 3.13 release version.
I can reproduce with Python 3.13.7 stdlib's http.client:
benz0li commentedon Aug 30, 2025
#112389 is the culprit.
Branch 3.13, commit ea1803e 👉 No SSLError
Branch 3.13, commit 0876b92 👉 SSLError
So it all boils down to #138193 (comment), i.e. whether an AKI that matches the SKI in a Root CA Certificate is supposed to be conisdered a malformation [by OpenSSL] or not.
benz0li commentedon Aug 30, 2025
Closed in favour of
VERIFY_X509_STRICT: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Missing Authority Key Identifier (_ssl.c:1032) openssl/openssl#28391nuclearpidgeon commentedon Nov 24, 2025
For practicality purposes for anyone else (I see a few linked issues) hitting this error behind a corporate HTTP proxy with self-signed certificates that you're not able to just get quickly re-provisioned...
One workaround if you can control the SSL context being used is to just disable the
VERIFY_X509_STRICTverification flag that is now set by default (courtesy @vstinner on #112389 (comment) ):This works as a solution for e.g. urllib3: urllib3/urllib3#3665 (comment)
As per the conversation above, /pull/112389 introduced the change causing the AKI validation behaviour by tightening the flags used in OpenSSL - it seems it got merged in to Python v3.13.0a5, so presumably it affects all 3.13 and later versions of Python.
dnsdist: Add X509v3 Authority Key Identifier to test certificates