Closed LTsCreed closed 1 month ago
Seems like checking for exc.strerror is None
first is the straightforward fix, but how to test for this properly?
Could you try with the linked PR? And it would also help to have a way to reproduce this.
Yes, it fixes the problem, thanks.
I have looked at other packages, and they don't perform additional checks for UNEXPECTED_EOF_WHILE_READING
. Why is it required here?
To reproduce the issue:
OS - Windows truststore==0.9.1 anyio==4.6.0 httpx==0.27.0
import asyncio
import ssl
import truststore
from httpx import AsyncClient
ts = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
client = AsyncClient(verify=ts)
async def main():
res = await client.get("https://wrong.host.badssl.com")
print(res.status_code)
asyncio.run(main())
Because, as I found, OpenSSL is weird and in some cases it didn't return the proper error code when an EOF occurs. I'd wager that most libraries don't even care about EOF in TLS streams. I'm hesitant to remove this check as it's not clear if this is still happening or not.
Things to check first
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
AnyIO version
4.6.0
Python version
3.11
What happened?
I encountered an issue while using httpx with truststore SSLContext. Specifically, when the TLS handshake fails, I receive the following error:
The root cause seems to be that ssl.SSLCertVerificationError exception is a subclass of ssl.SSLError, but it does not have a strerror attribute
How can we reproduce the bug?