Closed AndyXan closed 2 years ago
The context can now be supplied with
This would enable new user-land code when using the splunk-sdk-python after PR-Accept:
import ssl
import splunklib.client as client
context = ssl.create_default_context()
context.load_verify_locations("my-root-ca-cert.pem")
self.service = client.connect(host=self.host, app='my-app', port=8089,
username=self.username, scheme='https', password=self.password, verify=True, context=context)
And with optionally controlling the SLLContext, verifiy locations and tls-version specs etc. can be configured. The context object is optional, so it shouldn't break anything.
Thanks for PR @AndyXan , We have merged the PR and released a SDK version 1.6.17 with the changes.
Is your feature request related to a problem? Please describe. The Splunk Python SDK lacks the possibility to provide a custom ca certificate that is not installed in the local system certificates storage for server certificate validation.
The possible arguments (key_file, cert_file) are for client authentifaction - not for server certificate verficitation.
The problematic Code snippet is (current upstream): binding.py::1354
So, if verification is enabled - a default SSL Context is created and CA's
.pem
file have to be present in the system certificate storage. Otherwise it's an error like that:What's actually desired is to provide additional ssl lookup definitions:
Or in the above snippet from the original code in binding.py
Describe the solution you'd like
With the pull request, a User can optionally provide the entire SSLContext object with verify locations and all other settings, such as TLS-Version. A user can fully control the transport channel, which a user should be able to do.
The following parts of the code are slightly changes (details, see Pull Request).
Simply add a new argument that either allows the passing of a entire SSL-Context object or the CA-Verify-Locations at:
pass the new argument to HttpLib (either context or verify location)
self.handler = handler(verify=verify, key_file=key_file, cert_file=cert_file)
-> pass the argumentIt's not a big change - I am going to create a pull request tomorrow with the option to pass an entire SSLContext object to HTTPSConnection(...), thus enabling the user to specify custom ca certficates, tls versions and so on. I think the user should have the possibility to fully control the transport channel, if desired.
Best Regards
Describe alternatives you've considered The only alternative is to install custom ca certificates on the local system beforehand. This is suboptimal for certificates shipped with a packaged application and varies depending on the Operating System.
Additional context Add any other context or screenshots about the feature request here.