File: py3.12-key_file-and-cert_file-must-use-context.patch

package info (click to toggle)
python-magnumclient 4.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 988 kB
  • sloc: python: 9,888; makefile: 22; sh: 2
file content (32 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Description: key_file and cert_file must be used using context() api
Author: Thomas Goirand <zigo@debian.org>
Bug-Debian: https://bugs.debian.org/1058323
Forwarded: no
Last-Update: 2023-12-15

--- python-magnumclient-4.2.0.orig/magnumclient/common/httpclient.py
+++ python-magnumclient-4.2.0/magnumclient/common/httpclient.py
@@ -270,7 +270,11 @@
 
     def __init__(self, host, port, key_file=None, cert_file=None,
                  ca_file=None, timeout=None, insecure=False):
-        http_client.HTTPSConnection.__init__(self, host, port)
+
+        self.context = ssl.create_default_context()
+        if key_file and cert_file:
+            self.context.load_cert_chain(cert_file, key_file)
+
         self.key_file = key_file
         self.cert_file = cert_file
         if ca_file is not None:
@@ -280,6 +284,10 @@
         self.timeout = timeout
         self.insecure = insecure
 
+        http_client.HTTPSConnection.__init__(self, host, port,
+                                             context=self.context)
+
+
     def connect(self):
         """Connect to a host on a given (SSL) port.