-
Notifications
You must be signed in to change notification settings - Fork 187
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
Check OpenSSL environment variables before defaulting to certifi #196
Check OpenSSL environment variables before defaulting to certifi #196
Conversation
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
8f8428b
to
e14e3d9
Compare
I submitted the simplest implementation I could write but I do see several potential improvements depending on what people think:
|
@wbeckler @VachaShah could you approve running the workflows? |
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
Thanks a lot for the contribution! 👍
Yep, definitely would be good to have it in a single place.
Yep, good idea too.
I would not go there until there are real issues reported. Are they?
Could you please elaborate? What tests do you have in mind? |
Sounds good. Is putting it in the connection base module good enough or would you like it in a distinct/different module? (Distinct seems overkill to me, but I could see the benefit)
Not that I know of. The only potential issue I can think of would be that enabling this for the requests backend would override requests' default behavior by forcing certifi even when the CA_BUNDLE variables are set. Probably not an issue, since using requests should really be just an implementation detail, but it's probably something to track as a definite choice.
Just basic sanity tests to ensure the environment variables are properly read and the fallback to certify still occurs in their absence. Not strictly necessary, but nice to have. |
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
…ch-py into respect_openssl_env
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
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.
LGTM. Add to CHANGELOG and USER_GUIDE?
…ch-py into respect_openssl_env
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
@dblock Sorry for the delay, I've updated the docs. Please let me know if there is anything you'd like me to change. |
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.
LGTM, I think there's an opportunity to add a test here too
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
@dblock I added some tests to make sure each Connection implementation correctly handles the CA_CERTS constant, but I'm not sure how to test that SSL_CERT_FILE/DIR env vars are loaded properly without changing the implementation to delay loading the CA_CERTS until Connection instance initialization or adding much more complicated tests that either reload the related modules/start subprocesses. What's your opinion? |
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
5ff5aa6
to
4fca678
Compare
If you move the implementation of |
Add test cases for the different CA cert configurations Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
@dblock I had the same thought originally, so I went ahead and implemented it with tests. Let me know what you think. |
Perfect. @VachaShah help CR and let's merge this? |
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.
LGTM, thank you @aiudirog!
Workflows are failing for certain python versions for the latest ubuntu-22.04. Related issue on |
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
@VachaShah It doesn't look like those issues are going to be resolved soon, so I pushed a commit to implement the workarounds that were suggested |
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
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.
All good with me.
Let's document SSL configuration in https://github.com/opensearch-project/opensearch-py/blob/main/USER_GUIDE.md too, can be done in a future PR.
Description
Updated the urllib3 and aiohttp backends to check OpenSSL environment variables SSL_CERT_FILE/DIR before defaulting to certify's CA bundle to allow environmental configuration of custom SSL certificates.
Issues Resolved
Closes #111
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.