File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1- Upgrade truststore to 0.10.3
1+ Upgrade truststore to 0.10.4
Original file line number Diff line number Diff line change 3333del _api , _sys # type: ignore[name-defined] # noqa: F821
3434
3535__all__ = ["SSLContext" , "inject_into_ssl" , "extract_from_ssl" ]
36- __version__ = "0.10.3 "
36+ __version__ = "0.10.4 "
Original file line number Diff line number Diff line change 1+ import contextlib
12import os
23import platform
34import socket
45import ssl
56import sys
7+ import threading
68import typing
79
810import _ssl
@@ -84,6 +86,7 @@ def __class__(self) -> type:
8486
8587 def __init__ (self , protocol : int = None ) -> None : # type: ignore[assignment]
8688 self ._ctx = _original_SSLContext (protocol )
89+ self ._ctx_lock = threading .Lock ()
8790
8891 class TruststoreSSLObject (ssl .SSLObject ):
8992 # This object exists because wrap_bio() doesn't
@@ -106,10 +109,15 @@ def wrap_socket(
106109 server_hostname : str | None = None ,
107110 session : ssl .SSLSession | None = None ,
108111 ) -> ssl .SSLSocket :
109- # Use a context manager here because the
110- # inner SSLContext holds on to our state
111- # but also does the actual handshake.
112- with _configure_context (self ._ctx ):
112+
113+ # We need to lock around the .__enter__()
114+ # but we don't need to lock within the
115+ # context manager, so we need to expand the
116+ # syntactic sugar of the `with` statement.
117+ with contextlib .ExitStack () as stack :
118+ with self ._ctx_lock :
119+ stack .enter_context (_configure_context (self ._ctx ))
120+
113121 ssl_sock = self ._ctx .wrap_socket (
114122 sock ,
115123 server_side = server_side ,
Original file line number Diff line number Diff line change @@ -15,5 +15,5 @@ resolvelib==1.2.0
1515setuptools==70.3.0
1616tomli==2.2.1
1717tomli-w==1.2.0
18- truststore==0.10.3
18+ truststore==0.10.4
1919dependency-groups==1.3.1
You can’t perform that action at this time.
0 commit comments