diff --git a/backend/python/main.py b/backend/python/main.py index fec9c54..83b92a7 100644 --- a/backend/python/main.py +++ b/backend/python/main.py @@ -52,7 +52,11 @@ async def health(request): parser = argparse.ArgumentParser() parser.add_argument("--host", default="0.0.0.0") parser.add_argument("--port", type=int, default=8080) + parser.add_argument("--ssl-keyfile", default="") + parser.add_argument("--ssl-certfile", default="") + parser.add_argument("--ssl-ca-certs", default="") + parser.add_argument("--ssl-cert-reqs", type=int, default=0) args = parser.parse_args() - uvicorn.run(star, host=args.host, port=args.port) + uvicorn.run(star, host=args.host, port=args.port, ssl_keyfile=args.ssl_keyfile, ssl_certfile=args.ssl_certfile, ssl_ca_certs=args.ssl_ca_certs, ssl_cert_reqs=args.ssl_cert_reqs) diff --git a/frontend/python/main.py b/frontend/python/main.py index 1dc90d1..f2919fb 100644 --- a/frontend/python/main.py +++ b/frontend/python/main.py @@ -97,7 +97,7 @@ async def send_greeting(name, text): "text": text, } - async with AsyncClient() as client: + async with AsyncClient(verify=verify, cert=cert) as client: try: response = await client.post(f"{backend_url}/api/hello", json=request_data) except HTTPError as e: @@ -118,10 +118,23 @@ async def health(request): parser.add_argument("--host", default="0.0.0.0") parser.add_argument("--port", type=int, default=8080) parser.add_argument("--backend", metavar="URL", default="http://backend:8080") + parser.add_argument("--ssl-keyfile", default="") + parser.add_argument("--ssl-certfile", default="") + parser.add_argument("--ssl-ca-certs", default="") args = parser.parse_args() global backend_url backend_url = args.backend + global cert + if args.ssl_certfile and args.ssl_keyfile: + cert = (args.ssl_certfile, args.ssl_keyfile) + + global verify + if args.ssl_ca_certs: + verify = args.ssl_ca_certs + else: + verify = True + uvicorn.run(star, host=args.host, port=args.port)