Skip to content

Commit e629aed

Browse files
committed
Use SSL context
1 parent 6cd44b5 commit e629aed

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

kmip/services/kmip_client.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,16 @@ def open(self):
285285
six.reraise(*last_error)
286286

287287
def _create_socket(self, sock):
288-
self.socket = ssl.wrap_socket(
289-
sock,
288+
context = ssl.create_default_context()
289+
context.verify_mode = self.cert_reqs
290+
context.check_hostname = False
291+
context.load_cert_chain(
290292
keyfile=self.keyfile,
291-
certfile=self.certfile,
292-
cert_reqs=self.cert_reqs,
293-
ssl_version=self.ssl_version,
294-
ca_certs=self.ca_certs,
293+
certfile=self.certfile
294+
)
295+
context.load_verify_locations(cafile=self.ca_certs)
296+
self.socket = context.wrap_socket(
297+
sock,
295298
do_handshake_on_connect=self.do_handshake_on_connect,
296299
suppress_ragged_eofs=self.suppress_ragged_eofs)
297300
self.socket.settimeout(self.timeout)

kmip/services/server/server.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,20 @@ def interrupt_handler(trigger, frame):
287287
for cipher in auth_suite_ciphers:
288288
self._logger.debug(cipher)
289289

290-
self._socket = ssl.wrap_socket(
291-
self._socket,
292-
keyfile=self.config.settings.get('key_path'),
290+
context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
291+
context.verify_mode = ssl.CERT_REQUIRED
292+
context.check_hostname = False
293+
context.load_cert_chain(
293294
certfile=self.config.settings.get('certificate_path'),
295+
keyfile=self.config.settings.get('key_path'),
296+
)
297+
context.load_verify_locations(cafile=self.config.settings.get('ca_path'))
298+
context.set_ciphers(self.auth_suite.ciphers)
299+
self._socket = context.wrap_socket(
300+
self._socket,
294301
server_side=True,
295-
cert_reqs=ssl.CERT_REQUIRED,
296-
ssl_version=self.auth_suite.protocol,
297-
ca_certs=self.config.settings.get('ca_path'),
298302
do_handshake_on_connect=False,
299303
suppress_ragged_eofs=True,
300-
ciphers=self.auth_suite.ciphers
301304
)
302305

303306
try:

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,6 @@
7272
"Programming Language :: Python :: 3.9",
7373
"Programming Language :: Python :: 3.10",
7474
"Programming Language :: Python :: 3.11",
75+
"Programming Language :: Python :: 3.12",
7576
],
7677
)

0 commit comments

Comments
 (0)