aboutsummaryrefslogtreecommitdiff
path: root/blog_experiment/blog
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2023-10-08 13:42:58 +0200
committeralex <alex@pdp7.net>2023-10-08 13:43:29 +0200
commitd5b26f7041b9d0f8ce02435b5235d2aa931ec5e2 (patch)
tree1b196dbcac93b97ea8a3bca725c497cef02f78d4 /blog_experiment/blog
parent29a9cb3333d9c65572c53fec0a82a3ca7b4756da (diff)
Allow using a supplied certificate
Diffstat (limited to 'blog_experiment/blog')
-rw-r--r--blog_experiment/blog/__main__.py15
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()