Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise a More Specific Error for SSL_ERROR_SYSCALL? #1188

Closed
blink1073 opened this issue Feb 21, 2023 · 5 comments
Closed

Raise a More Specific Error for SSL_ERROR_SYSCALL? #1188

blink1073 opened this issue Feb 21, 2023 · 5 comments

Comments

@blink1073
Copy link

Hi, thanks for this library! We noticed that in some cases PyOpenSSL returns error messages of the form OpenSSL.SSL.SysCallError: (54, 'ECONNRESET'), whereas the equivalent condition when using the builtin ssl module would raise a ConnectionError with the str() form containing Connection reset by peer. I believe this comes from the use of PyErr_SetFromErrno, versus the custom SysCallError. Given that PyOpenSSL is pure Python, I imagine some custom logic would be needed to achieve the same.

@alex
Copy link
Member

alex commented Feb 21, 2023

It's a bit verbose, but you should be able to get that value with os.strerror(e.args[0])

@ShaneHarvey
Copy link
Contributor

When the server is configured to require a client cert but the client does not present one, we would expect to see an error with "certificate required", "SSL handshake failed", "Connection reset by peer", or one of the equivalent errnos (like ECONNRESET) but we're actually seeing pyopenssl raise (32, 'EPIPE') on macOS (in https://jira.mongodb.org/browse/PYTHON-3607). My understanding is that EPIPE indicates a bug in openssl/pyopenssl, what do you think?

@alex
Copy link
Member

alex commented Feb 22, 2023 via email

@ShaneHarvey
Copy link
Contributor

Good point, opened #1189.

@facutuesca
Copy link
Contributor

The original issue seems to be solved (using os.strerror to get the readable string description of the error code).

@mhils I think this one can be closed

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants