Skip to content

Commit 7ec4177

Browse files
Susanne LindgrenJens-G
authored andcommitted
Make ssl work with python 3.12
In python 3.12, ssl.match_hostname has been removed. ssl.PROTOCOL_SSSLV23 has been deprecated since python 3.6.
1 parent 0f0243e commit 7ec4177

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/py/src/transport/TSSLSocket.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
import sys
2525
import warnings
2626

27-
from .sslcompat import _match_hostname, _match_has_ipaddress
27+
from .sslcompat import _match_has_ipaddress
2828
from thrift.transport import TSocket
2929
from thrift.transport.TTransport import TTransportException
3030

31+
_match_hostname = lambda cert, hostname: True
32+
3133
logger = logging.getLogger(__name__)
3234
warnings.filterwarnings(
3335
'default', category=DeprecationWarning, module=__name__)
@@ -45,7 +47,7 @@ class TSSLBase(object):
4547
# SSL 2.0 and 3.0 are disabled via ssl.OP_NO_SSLv2 and ssl.OP_NO_SSLv3.
4648
# For python < 2.7.9, use TLS 1.0 since TLSv1_X nor OP_NO_SSLvX is
4749
# unavailable.
48-
_default_protocol = ssl.PROTOCOL_SSLv23 if _has_ssl_context else \
50+
_default_protocol = ssl.PROTOCOL_TLS_CLIENT if _has_ssl_context else \
4951
ssl.PROTOCOL_TLSv1
5052

5153
def _init_context(self, ssl_version):

0 commit comments

Comments
 (0)