Skip to content

Instantly share code, notes, and snippets.

@abuxton
Forked from magnuswatn/get_ca_bundle.py
Created January 21, 2022 14:57
Show Gist options
  • Save abuxton/61871d8f9347df2ffdbf8c94d3684199 to your computer and use it in GitHub Desktop.
Save abuxton/61871d8f9347df2ffdbf8c94d3684199 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