|
38 | 38 | ) |
39 | 39 | from pymongo.network_layer import AsyncNetworkingInterface, NetworkingInterface, PyMongoProtocol |
40 | 40 | from pymongo.pool_options import PoolOptions |
41 | | -from pymongo.ssl_support import HAS_SNI, SSLError |
| 41 | +from pymongo.ssl_support import HAS_SNI, PYSSLError, SSLError |
42 | 42 |
|
43 | 43 | if TYPE_CHECKING: |
44 | 44 | from pymongo.pyopenssl_context import _sslConn |
@@ -138,7 +138,7 @@ def _raise_connection_failure( |
138 | 138 | msg += format_timeout_details(timeout_details) |
139 | 139 | if isinstance(error, socket.timeout): |
140 | 140 | raise NetworkTimeout(msg) from error |
141 | | - elif isinstance(error, SSLError) and "timed out" in str(error): |
| 141 | + elif isinstance(error, (SSLError, PYSSLError)) and "timed out" in str(error): |
142 | 142 | # Eventlet does not distinguish TLS network timeouts from other |
143 | 143 | # SSLErrors (https://github.com/eventlet/eventlet/issues/692). |
144 | 144 | # Luckily, we can work around this limitation because the phrase |
@@ -293,7 +293,7 @@ async def _async_configured_socket( |
293 | 293 | # Raise _CertificateError directly like we do after match_hostname |
294 | 294 | # below. |
295 | 295 | raise |
296 | | - except (OSError, SSLError) as exc: |
| 296 | + except (OSError, SSLError, PYSSLError) as exc: |
297 | 297 | sock.close() |
298 | 298 | # We raise AutoReconnect for transient and permanent SSL handshake |
299 | 299 | # failures alike. Permanent handshake failures, like protocol |
@@ -349,7 +349,7 @@ async def _configured_protocol_interface( |
349 | 349 | # Raise _CertificateError directly like we do after match_hostname |
350 | 350 | # below. |
351 | 351 | raise |
352 | | - except (OSError, SSLError) as exc: |
| 352 | + except (OSError, SSLError, PYSSLError) as exc: |
353 | 353 | # We raise AutoReconnect for transient and permanent SSL handshake |
354 | 354 | # failures alike. Permanent handshake failures, like protocol |
355 | 355 | # mismatch, will be turned into ServerSelectionTimeoutErrors later. |
@@ -467,7 +467,7 @@ def _configured_socket(address: _Address, options: PoolOptions) -> Union[socket. |
467 | 467 | # Raise _CertificateError directly like we do after match_hostname |
468 | 468 | # below. |
469 | 469 | raise |
470 | | - except (OSError, SSLError) as exc: |
| 470 | + except (OSError, SSLError, PYSSLError) as exc: |
471 | 471 | sock.close() |
472 | 472 | # We raise AutoReconnect for transient and permanent SSL handshake |
473 | 473 | # failures alike. Permanent handshake failures, like protocol |
@@ -516,7 +516,7 @@ def _configured_socket_interface(address: _Address, options: PoolOptions) -> Net |
516 | 516 | # Raise _CertificateError directly like we do after match_hostname |
517 | 517 | # below. |
518 | 518 | raise |
519 | | - except (OSError, SSLError) as exc: |
| 519 | + except (OSError, SSLError, PYSSLError) as exc: |
520 | 520 | sock.close() |
521 | 521 | # We raise AutoReconnect for transient and permanent SSL handshake |
522 | 522 | # failures alike. Permanent handshake failures, like protocol |
|
0 commit comments