Skip to content

Configure SSL CA CERTIFICATE with REQUESTS_CA_BUNDLE env var before certifi #1131

Open
@nirousseau

Description

@nirousseau

What is the feature and why do you need it:

The idea is to configure ssl_ca_cert using the REQUESTS_CA_BUNDLE env var before falling back to certifi if no specific configuration has been provided.

Some applications that are using kubernetes-client / python do not provide a parameter to client/configuration.py#L83. Using an env var before certifi will help such use cases.

Finally, it can be very useful in a container context, as we can pass this configuration via, once again, env vars.

Describe the solution you'd like to see:

In :
client/rest.py#L70

At the moment, the code is the following :

        # ca_certs
        if configuration.ssl_ca_cert:
            ca_certs = configuration.ssl_ca_cert
        else:
            # if not set certificate file, use Mozilla's root certificates.
            ca_certs = certifi.where()

We can add a new condition of the form :

        # ca_certs
        if configuration.ssl_ca_cert:
            ca_certs = configuration.ssl_ca_cert
        elif 'REQUESTS_CA_BUNDLE' in os.environ:
            ca_certs = environ.get('REQUESTS_CA_BUNDLE')
        else:
            # if not set certificate file, use Mozilla's root certificates.
            ca_certs = certifi.where()

The env var REQUESTS_CA_BUNDLE seems to be a good candidate as it is a common practice.

Related issues:

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions