Serve challenge server

This commit is contained in:
Fang-Pen Lin
2025-11-07 09:19:12 -08:00
parent 5d31627afd
commit 3a05ad8cd1
2 changed files with 20 additions and 1 deletions
@@ -17,4 +17,5 @@ Feature: Challenge
Then I sign the certificate signing request csr with private key cert_key and output it as csr_pem in PEM format Then I sign the certificate signing request csr with private key cert_key and output it as csr_pem in PEM format
Then I submit the certificate signing request PEM csr_pem certificate order to the ACME server as order Then I submit the certificate signing request PEM csr_pem certificate order to the ACME server as order
Then I select challenge with type http-01 for domain localhost from order at order as challenge Then I select challenge with type http-01 for domain localhost from order at order as challenge
Then I serve challenge response for challenge at localhost
+19 -1
View File
@@ -6,6 +6,7 @@ import requests
import glom import glom
from acme import client from acme import client
from acme import messages from acme import messages
from acme import standalone
from behave.runner import Context from behave.runner import Context
from behave import given from behave import given
from behave import when from behave import when
@@ -340,4 +341,21 @@ def step_impl(
raise ValueError( raise ValueError(
f"More than one authorization for type {challenge_type!r} found in {var_path!r}" f"More than one authorization for type {challenge_type!r} found in {var_path!r}"
) )
context.vars[challenge_var] = auths[0] context.vars[challenge_var] = challenges[0]
@then("I serve challenge response for {var_path} at {hostname}")
def step_impl(context: Context, var_path: str, hostname: str):
if hostname != "localhost":
raise ValueError("Currently only localhost is supported")
challenge = eval_var(context, var_path, as_json=False)
acme_challenge = challenge.chall
response, validation = acme_challenge.response_and_validation(
context.acme_client.net.key
)
resource = standalone.HTTP01RequestHandler.HTTP01Resource(
chall=acme_challenge, response=response, validation=validation
)
servers = standalone.HTTP01DualNetworkedServers(("", 8087), resource)
# Start client standalone web server.
servers.serve_forever()