Skip to content

Instantly share code, notes, and snippets.

@magnuswatn
Created July 18, 2018 22:31
Show Gist options
  • Save magnuswatn/228957f88cab75f43fa73d4ce36985b6 to your computer and use it in GitHub Desktop.
Save magnuswatn/228957f88cab75f43fa73d4ce36985b6 to your computer and use it in GitHub Desktop.
def get_ca_bundle():
"""Tries to find the platform ca bundle for the system (on linux systems)"""
ca_bundles = [
# list taken from https://golang.org/src/crypto/x509/root_linux.go
"/etc/ssl/certs/ca-certificates.crt", # Debian/Ubuntu/Gentoo etc.
"/etc/pki/tls/certs/ca-bundle.crt", # Fedora/RHEL 6
"/etc/ssl/ca-bundle.pem", # OpenSUSE
"/etc/pki/tls/cacert.pem", # OpenELEC
"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem", # CentOS/RHEL 7
]
for ca_bundle in ca_bundles:
if os.path.isfile(ca_bundle):
return ca_bundle
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment