Skip to content

Commit 6c9a20a

Browse files
authored
PYTHON-5014 Tests that use HTTPSConnection should only use stdlib ssl (#2053)
1 parent 53943ac commit 6c9a20a

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

test/asynchronous/test_encryption.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
WriteError,
9999
)
100100
from pymongo.operations import InsertOne, ReplaceOne, UpdateOne
101-
from pymongo.ssl_support import get_ssl_context
102101
from pymongo.write_concern import WriteConcern
103102

104103
_IS_SYNC = False
@@ -2879,15 +2878,8 @@ async def asyncSetUp(self):
28792878
async def http_post(self, path, data=None):
28802879
# Note, the connection to the mock server needs to be closed after
28812880
# each request because the server is single threaded.
2882-
ctx: ssl.SSLContext = get_ssl_context(
2883-
CLIENT_PEM, # certfile
2884-
None, # passphrase
2885-
CA_PEM, # ca_certs
2886-
None, # crlfile
2887-
False, # allow_invalid_certificates
2888-
False, # allow_invalid_hostnames
2889-
False, # disable_ocsp_endpoint_check
2890-
)
2881+
ctx = ssl.create_default_context(cafile=CA_PEM)
2882+
ctx.load_cert_chain(CLIENT_PEM)
28912883
conn = http.client.HTTPSConnection("127.0.0.1:9003", context=ctx)
28922884
try:
28932885
if data is not None:

test/test_encryption.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
WriteError,
9696
)
9797
from pymongo.operations import InsertOne, ReplaceOne, UpdateOne
98-
from pymongo.ssl_support import get_ssl_context
9998
from pymongo.synchronous import encryption
10099
from pymongo.synchronous.encryption import Algorithm, ClientEncryption, QueryType
101100
from pymongo.synchronous.mongo_client import MongoClient
@@ -2861,15 +2860,8 @@ def setUp(self):
28612860
def http_post(self, path, data=None):
28622861
# Note, the connection to the mock server needs to be closed after
28632862
# each request because the server is single threaded.
2864-
ctx: ssl.SSLContext = get_ssl_context(
2865-
CLIENT_PEM, # certfile
2866-
None, # passphrase
2867-
CA_PEM, # ca_certs
2868-
None, # crlfile
2869-
False, # allow_invalid_certificates
2870-
False, # allow_invalid_hostnames
2871-
False, # disable_ocsp_endpoint_check
2872-
)
2863+
ctx = ssl.create_default_context(cafile=CA_PEM)
2864+
ctx.load_cert_chain(CLIENT_PEM)
28732865
conn = http.client.HTTPSConnection("127.0.0.1:9003", context=ctx)
28742866
try:
28752867
if data is not None:

0 commit comments

Comments
 (0)