From 2f471a7905d5c4f7baa6274202b9222a1bbfd3eb Mon Sep 17 00:00:00 2001 From: chkp-edenbr <94056191+chkp-edenbr@users.noreply.github.com> Date: Mon, 27 Nov 2023 14:16:00 +0200 Subject: [PATCH] Python 3.12 ssl compatibility fix (#57) * Add sg file * Revert "Add sg file" This reverts commit 726298c13acc2f51fccda85035d2b56c23ef4f4f. * Python 3.12 ssl compatibility fix --- cpapi/mgmt_api.py | 6 +++--- setup.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpapi/mgmt_api.py b/cpapi/mgmt_api.py index 9a6a834..83d2396 100644 --- a/cpapi/mgmt_api.py +++ b/cpapi/mgmt_api.py @@ -748,8 +748,8 @@ def read_fingerprint_from_file(server, filename="fingerprints.txt"): return "" def create_https_connection(self): - context = ssl.create_default_context() - context.check_hostname = True + context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS) + context.verify_mode = ssl.CERT_NONE # create https connection if self.proxy_host and self.proxy_port: conn = HTTPSConnection(self.proxy_host, self.proxy_port, context=context) @@ -784,7 +784,7 @@ class HTTPSConnection(http_client.HTTPSConnection): """ def connect(self): http_client.HTTPConnection.connect(self) - self.sock = ssl.wrap_socket(self.sock, self.key_file, self.cert_file, cert_reqs=ssl.CERT_NONE) + self.sock = self._context.wrap_socket(self.sock, server_hostname=self.host) def get_fingerprint_hash(self): if self.sock is None: diff --git a/setup.py b/setup.py index b274b14..9b5a5b1 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="cp-mgmt-api-sdk", - version="1.7.0", + version="1.8.0", author="API team", author_email="api_team@checkpoint.com", license='Apache 2.0',