diff options
| author | alex <alex@pdp7.net> | 2023-10-08 13:42:58 +0200 |
|---|---|---|
| committer | alex <alex@pdp7.net> | 2023-10-08 13:43:29 +0200 |
| commit | d5b26f7041b9d0f8ce02435b5235d2aa931ec5e2 (patch) | |
| tree | 1b196dbcac93b97ea8a3bca725c497cef02f78d4 | |
| parent | 29a9cb3333d9c65572c53fec0a82a3ca7b4756da (diff) | |
Allow using a supplied certificate
| -rw-r--r-- | blog_experiment/blog/__main__.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/blog_experiment/blog/__main__.py b/blog_experiment/blog/__main__.py index b936500d..afe50c53 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() |
