diff --git a/backend/main.py b/backend/main.py index af02a9f..a2f2a8b 100644 --- a/backend/main.py +++ b/backend/main.py @@ -104,6 +104,16 @@ if __name__ == "__main__": key_path = "ssl/key.pem" host = "127.0.0.1" print("Running in CI mode with self-signed certificates...") + # Ensure SSL certificate and key are generated + if is_ci or environment == "dev": + Path("ssl").mkdir(exist_ok=True) + + if not Path(cert_path).exists() or not Path(key_path).exists(): + print( + f"Generating self-signed SSL certificate" + f"at {cert_path} and {key_path}" + ) + ssl_heidi.generate_self_signed_cert(cert_path, key_path) elif environment == "test": cert_path = "ssl/mx-aare-test.psi.ch.pem" key_path = "ssl/mx-aare-test.psi.ch.key"