diff options
Diffstat (limited to 'docker/auto-certbot/get-cert-domains.py')
-rwxr-xr-x | docker/auto-certbot/get-cert-domains.py | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/docker/auto-certbot/get-cert-domains.py b/docker/auto-certbot/get-cert-domains.py deleted file mode 100755 index 9bd28c8..0000000 --- a/docker/auto-certbot/get-cert-domains.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -from os.path import * -from cryptography.x509 import * -from cryptography.x509.oid import ExtensionOID - -# Check only one argument -if len(sys.argv) != 2: - print("You should only specify one argument, aka, the path of cert.", - file=sys.stderr) - exit(1) - -cert_path = sys.argv[1] - -if not exists(cert_path): - print("Cert file does not exist.", file=sys.stderr) - exit(2) - -if not isfile(cert_path): - print("Cert path is not a file.") - exit(3) - -if not 'CRUPEST_DOMAIN' in os.environ: - print("Please set CRUPEST_DOMAIN environment variable to root domain.", file=sys.stderr) - exit(4) - -root_domain = os.environ['CRUPEST_DOMAIN'] - -with open(cert_path, 'rb') as f: - cert = load_pem_x509_certificate(f.read()) - ext = cert.extensions.get_extension_for_oid( - ExtensionOID.SUBJECT_ALTERNATIVE_NAME) - domains: list = ext.value.get_values_for_type(DNSName) - domains.remove(root_domain) - domains = [root_domain, *domains] - print('\n'.join(domains)) |