Improve SSL error handling with specific exception types#1542
Merged
maurosoria merged 3 commits intoApr 28, 2026
Conversation
…soria#1444) Replace fragile string-based SSL error detection with proper isinstance checks and provide specific, actionable error messages instead of the generic 'Unexpected SSL error' message. Changes in Requester (sync): - Replace '"SSLError" in str(e)' with isinstance checks using ssl.SSLError and detection of requests-wrapped SSL errors via exception chain inspection - Use _format_ssl_error() for detailed error messages Changes in AsyncRequester (async): - Use _format_ssl_error() instead of generic 'Unexpected SSL error' New helper functions: - _is_requests_ssl_error(): Detects SSL errors wrapped by the requests library (requests.exceptions.SSLError) by walking the exception cause chain (PEP 3134) - _format_ssl_error(): Provides specific error messages for common SSL errors: - Certificate verification failures (self-signed, expired, not yet valid, missing issuer, hostname mismatch) - SSL handshake failures - Protocol version mismatches - Cipher suite negotiation failures - Unexpected connection termination - Falls back to library/reason from ssl.SSLError attributes Also adds proper warning-level logging for SSL errors with details (library, reason, error detail) to aid debugging. Closes: maurosoria#1444
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace string-based SSL error detection with isinstance checks and provide specific actionable error messages. Closes #1444