Uncomment challenge verification

This commit is contained in:
clement committed 2026-11-03 17:01:55 +01:00
1 parent ac94eccea5
commit a08546221f
2 files changed
+16 -15

No files matched your search

+16 -15
View File
@@ -5,6 +5,7 @@ from pathlib import Path
from secrets import token_urlsafe
from typing import cast
import httpx
from cryptography import x509
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric.types import (
@@ -18,7 +19,7 @@ from app.types import CSR, CertificateChainResponse
CONFIG_DIR = Path("config")
if not path.exists(CONFIG_DIR):
raise RuntimeError(
f"Configuration directory '{CONFIG_DIR}' does not exist. Please create it and add the necessary files."
f"Configuration directory '{CONFIG_DIR}' does not exist. Please create it using ./init.sh"
)
CA_PRIVATE_KEY = cast(
@@ -77,20 +78,20 @@ async def finalize_order(order_id: str, req: FinalizeRequest):
)
order = orders[order_id]
# try:
# well_known_url = f"http://{order.domain}:{order.port}/.well-known/acme-challenge/{order.authorization}"
# async with httpx.AsyncClient() as client:
# resp = await client.get(well_known_url, timeout=5)
# if resp.status_code != 200 or resp.text.strip() != order.authorization:
# raise HTTPException(
# status_code=status.HTTP_400_BAD_REQUEST,
# detail="Invalid challenge",
# )
# except httpx.RequestError:
# raise HTTPException(
# status_code=status.HTTP_400_BAD_REQUEST,
# detail="Challenge request failed",
# )
try:
well_known_url = f"http://{order.domain}:{order.port}/.well-known/acme-challenge/{order.authorization}"
async with httpx.AsyncClient() as client:
resp = await client.get(well_known_url, timeout=5)
if resp.status_code != 200 or resp.text.strip() != order.authorization:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Invalid challenge",
)
except httpx.RequestError:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Challenge request failed",
)
cert_builder = (
x509.CertificateBuilder()