Skip to content

Commit

Permalink
Allow specifying a custom CA bundle file
Browse files Browse the repository at this point in the history
In some cases, we may want to keep SSL certificate verification set,
but use our own CA bundle file when connecting to an SSL -enabled
API server.

This commit adds a check for a new environment variable, SSL_CA_BUNDLE.
When set, it will instruct the client to use that file to verify SSL
certificates, instead of the default one provided by certifi.

Change-Id: I7f26798d7e1bd91493a12ca6f7e4c6f6fde57482
  • Loading branch information
javierpena committed Oct 6, 2021
1 parent 83fe650 commit ad21fe7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.rst
Expand Up @@ -136,6 +136,9 @@ Environment variables
API.
- *SSL_VERIFY*: set to ‘0’ to deactivate SSL verification when talking
to the DLRN API.
- *SSL_CA_BUNDLE*: when set to a value, it will instruct the client to
use that file to verify SSL certificates, instead of the default CA
bundle provided by `certifi`.

Author
------
Expand Down
4 changes: 3 additions & 1 deletion dlrnapi_client/configuration.py
Expand Up @@ -82,7 +82,9 @@ def __init__(self):
else:
self.verify_ssl = True
# Set this to customize the certificate file to verify the peer.
self.ssl_ca_cert = None
# If SSL_CA_BUNDLE is not set, self.ssl_ca_cert will be None,
# so we will use the CA bundle provided by certifi
self.ssl_ca_cert = os.environ.get('SSL_CA_BUNDLE')
# client certificate file
self.cert_file = None
# client key file
Expand Down

0 comments on commit ad21fe7

Please sign in to comment.