Skip to content

Commit

Permalink
Do not use ssl.wrap_socket removed in Python 3.12
Browse files Browse the repository at this point in the history
Fixes beaker-project#188

Signed-off-by: Michael Hofmann <mhofmann@redhat.com>
  • Loading branch information
mh21 authored and StykMartin committed Nov 17, 2023
1 parent 9551a07 commit cd2b74b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Common/bkr/common/xmlrpc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def begin(self):
self.close()
raise socket.error(1001, response.status, response.msg)

self.sock = ssl.wrap_socket(self.sock, keyfile=self.key_file, certfile=self.cert_file)
context = ssl.create_default_context()
if self.cert_file:
context.load_cert_chain(self.cert_file, self.key_file)
self.sock = context.wrap_socket(self.sock, server_hostname=self.real_host)

def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
return TimeoutHTTPConnection.putrequest(self, method, url)
Expand Down
5 changes: 4 additions & 1 deletion Common/bkr/common/xmlrpc3.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ def begin(self):
self.close()
raise socket.error(1001, response.status, response.msg)

self.sock = ssl.wrap_socket(self.sock, keyfile=self.key_file, certfile=self.cert_file)
context = ssl.create_default_context()
if self.cert_file:
context.load_cert_chain(self.cert_file, self.key_file)
self.sock = context.wrap_socket(self.sock, server_hostname=self.real_host)

def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
return TimeoutHTTPConnection.putrequest(self, method, url)
Expand Down

0 comments on commit cd2b74b

Please sign in to comment.