Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gabbi doesn't support client cert yet #315

Open
wu-wenxiang opened this issue Jun 15, 2022 · 4 comments
Open

gabbi doesn't support client cert yet #315

wu-wenxiang opened this issue Jun 15, 2022 · 4 comments

Comments

@wu-wenxiang
Copy link

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 ...

@wu-wenxiang
Copy link
Author

wu-wenxiang commented Jun 15, 2022

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
Copy link
Author

we should pass cmd line args to here...

@cdent
Copy link
Owner

cdent commented Jun 15, 2022

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?

@wu-wenxiang
Copy link
Author

wu-wenxiang commented Jun 15, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants