Procházet zdrojové kódy

Dealing with non user cert required https servers

Andrej před 4 roky
rodič
revize
b1bbca9ead
1 změnil soubory, kde provedl 11 přidání a 5 odebrání
  1. 11 5
      labkeyInterface.py

+ 11 - 5
labkeyInterface.py

@@ -19,11 +19,17 @@ class labkeyInterface:
         self.http=urllib3.PoolManager()
 
         if 'SSL' in self.connectionConfig:
-            self.http = urllib3.PoolManager(\
-                cert_file=self.connectionConfig['SSL']['user'],\
-                cert_reqs='CERT_REQUIRED',\
-                key_file=self.connectionConfig['SSL']['key'],\
-                ca_certs=self.connectionConfig['SSL']['ca'])
+            try:
+                self.http = urllib3.PoolManager(\
+                    cert_file=self.connectionConfig['SSL']['user'],\
+                    cert_reqs='CERT_REQUIRED',\
+                    key_file=self.connectionConfig['SSL']['key'],\
+                    ca_certs=self.connectionConfig['SSL']['ca'])
+            except KeyError:
+                self.http = urllib3.PoolManager(\
+                    cert_reqs='CERT_REQUIRED',\
+                    ca_certs=self.connectionConfig['SSL']['ca'])
+
 
     #password=self.connectionConfig['SSL']['keyPwd'],\ doesnt work until 1.25
     def GetLabkeyUrl(self):