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 33
33
del _api , _sys # type: ignore[name-defined] # noqa: F821
34
34
35
35
__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
1
2
import os
2
3
import platform
3
4
import socket
4
5
import ssl
5
6
import sys
7
+ import threading
6
8
import typing
7
9
8
10
import _ssl
@@ -84,6 +86,7 @@ def __class__(self) -> type:
84
86
85
87
def __init__ (self , protocol : int = None ) -> None : # type: ignore[assignment]
86
88
self ._ctx = _original_SSLContext (protocol )
89
+ self ._ctx_lock = threading .Lock ()
87
90
88
91
class TruststoreSSLObject (ssl .SSLObject ):
89
92
# This object exists because wrap_bio() doesn't
@@ -106,10 +109,15 @@ def wrap_socket(
106
109
server_hostname : str | None = None ,
107
110
session : ssl .SSLSession | None = None ,
108
111
) -> 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
+
113
121
ssl_sock = self ._ctx .wrap_socket (
114
122
sock ,
115
123
server_side = server_side ,
Original file line number Diff line number Diff line change @@ -15,5 +15,5 @@ resolvelib==1.2.0
15
15
setuptools==70.3.0
16
16
tomli==2.2.1
17
17
tomli-w==1.2.0
18
- truststore==0.10.3
18
+ truststore==0.10.4
19
19
dependency-groups==1.3.1
You can’t perform that action at this time.
0 commit comments