gabbi icon indicating copy to clipboard operation
gabbi copied to clipboard

gabbi doesn't support client cert yet

Open ghost opened this issue 3 years ago • 4 comments

Gabbi doesn't support client cert yet

Help gabbi could support: gabbi-run ... --cacert /etc/kubernetes/pki/ca.crt --cert /etc/kubernetes/pki/client.crt --key /etc/kubernetes/pki/client.key ...

ghost avatar Jun 15 '22 14:06 ghost

diff --git a/gabbi/httpclient.py b/gabbi/httpclient.py
index b64b8a2..3dbff1b 100644
--- a/gabbi/httpclient.py
+++ b/gabbi/httpclient.py
@@ -186,11 +186,17 @@ class VerboseHttp(Http):
 def get_http(verbose=False, caption='', cert_validate=True, hostname=None):
     """Return an ``Http`` class for making requests."""
     cert_validation = {'cert_reqs': 'CERT_NONE'} if not cert_validate else {}
+    cert_validation = {
+        'cert_file': '/Users/wuwenxiang/Desktop/test.crt',
+        'cert_reqs': "CERT_REQUIRED",
+        'ca_certs': '/Users/wuwenxiang/Desktop/test.cacert',
+        'key_file': "/Users/wuwenxiang/Desktop/test.key",
+    }
 
     if not verbose:
         return Http(
             strict=True,
-            ca_certs=certifi.where(),
+            # ca_certs=certifi.where(),
             server_hostname=hostname,
             **cert_validation
         )
@@ -205,7 +211,7 @@ def get_http(verbose=False, caption='', cert_validate=True, hostname=None):
         caption=caption,
         colorize=True,
         strict=True,
-        ca_certs=certifi.where(),
+        # ca_certs=certifi.where(),
         server_hostname=hostname,
         **cert_validation
     )

wu-wenxiang avatar Jun 15 '22 15:06 wu-wenxiang

we should pass cmd line args to here...

wu-wenxiang avatar Jun 15 '22 15:06 wu-wenxiang

Thanks, this is a good idea.

It will take some thought to work out how best to integrate it with the command line and with test suites, but we would be able to figure it out.

Did you have any ideas on whether it should be expressed in the YAML files?

cdent avatar Jun 15 '22 20:06 cdent

Be expressed in the YAML files seems better! It could be used both in fixtures & single case in tests

wu-wenxiang avatar Jun 15 '22 23:06 wu-wenxiang