From: alex Date: Sun, 8 Oct 2023 11:42:58 +0000 (+0200) Subject: Allow using a supplied certificate X-Git-Tag: 20240214-emacs~250 X-Git-Url: https://xn--ix-yja.es/gitweb/?a=commitdiff_plain;h=d5b26f7041b9d0f8ce02435b5235d2aa931ec5e2;p=alex.git Allow using a supplied certificate --- diff --git a/blog_experiment/blog/__main__.py b/blog_experiment/blog/__main__.py index b936500..afe50c5 100644 --- a/blog_experiment/blog/__main__.py +++ b/blog_experiment/blog/__main__.py @@ -1,4 +1,6 @@ +import argparse import logging +import sys from bicephalus import main as bicephalus_main from bicephalus import otel @@ -9,9 +11,20 @@ import blog def main(): otel.configure_logging(logging.INFO) + + parser = argparse.ArgumentParser() + parser.add_argument("--key-cert", nargs=2, metavar=("KEY", "CERT",), help="Path to a key and a file") + args = parser.parse_args() + + if args.key_cert: + key, cert = args.key_cert + with ssl.ssl_context_from_files(cert, key) as ssl_context: + bicephalus_main.main(blog.handler, ssl_context, 8000) + sys.exit(0) + with ssl.temporary_ssl_context("localhost") as ssl_context: bicephalus_main.main(blog.handler, ssl_context, 8000) - + sys.exit(0) if __name__ == "__main__": main()