-
-
Notifications
You must be signed in to change notification settings - Fork 228
feat: Add verify_ssl to generated Client, allowing users of generated libraries to ignore ssl verification #497
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
feat: Add verify_ssl to generated Client, allowing users of generated libraries to ignore ssl verification #497
Conversation
Awesome, thanks for the contribution @rtaycher ! I've approved CI so it can run, once that passes this is just about good to go. I think we should probably add a note somewhere for users so they know they can do this, maybe in the generated README? I don't actually know how much we have in there right now around Client usage, I might need to make a separate PR to give it some love. |
Codecov Report
@@ Coverage Diff @@
## main #497 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 48 48
Lines 1609 1609
=========================================
Hits 1609 1609 Continue to review full report at Codecov.
|
Does By default when you're calling an https api it will attempt to verify that ssl is working correctly. client = AuthenticatedClient(base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl='/path/to/certificate_bundle.pem') or even disable ssl verification altogether, despite the fact that it can increase security risks. client = AuthenticatedClient(base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False) sound ok? |
That sounds great @rtaycher! I think the README is the right place for now, at least until we have a better overall docstring strategy. |
README updated |
Do I need to add anything else? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks! I made a couple tweaks in the wording but once CI checks pass I'll merge this!
Sometimes (especially when dealing with internal applications) its necessary to ignore ssl checks.
This lets you configure it on the generated Client class and passes it on to any httpx.get/put/post/patch/delete calls
This should work with issue #202 when it gets finished, only thing is that I think they will need to use attr.ib on_setattr= argument to recreate the client instance when verify_ssl is modified, since in the httpx.Client class verify is set in the Constructor of the httpx.Client and not on get/put/post/patch/delete methods of the class.
One other question is whether the type of
verify_ssl: Union[str, bool, ssl.SSLContext] should or should not contain ssl.SSLContext or str.
I think you can do fancy and useful things with ssl.SSLContext like load self signed certs to check but I don't think requests allows it, and I'm not sure about other http libraries with a verify parameter. I think both httpx and requests let you take a string path to a certificate bundle, but am not sure about the details.
Personally I think it should be [str, bool, ssl.SSLContext] for flexibility.