Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Override host for acme challenge
Fang-Pen Lind80a5414a571
diff --git a/backend/src/ee/services/pki-acme/pki-acme-challenge-service.ts b/backend/src/ee/services/pki-acme/pki-acme-challenge-service.tsindex e6464d69c1..26dc65aaf8 100644--- a/backend/src/ee/services/pki-acme/pki-acme-challenge-service.ts+++ b/backend/src/ee/services/pki-acme/pki-acme-challenge-service.ts@@ -49,11 +49,15 @@ export const pkiAcmeChallengeServiceFactory = ({if (challenge.type !== AcmeChallengeType.HTTP_01) {throw new BadRequestError({ message: "Only HTTP-01 challenges are supported for now" });}- const baseUrl = `http://${challenge.auth.identifierValue}`;- const actualBaseUrl = appCfg.isAcmeDevelopmentMode- ? `${baseUrl}:${appCfg.ACME_DEVELOPMENT_HTTP01_CHALLENGE_PORT}`- : baseUrl;- const challengeUrl = new URL(`/.well-known/acme-challenge/${challenge.auth.token}`, actualBaseUrl);+ let host = challenge.auth.identifierValue;+ if (appCfg.isAcmeDevelopmentMode && appCfg.ACME_DEVELOPMENT_HTTP01_CHALLENGE_HOST_OVERRIDES[host]) {+ host = appCfg.ACME_DEVELOPMENT_HTTP01_CHALLENGE_HOST_OVERRIDES[host];+ logger.warn(+ { srcHost: challenge.auth.identifierValue, dstHost: host },+ "Using ACME development HTTP-01 challenge host override"+ );+ }+ const challengeUrl = new URL(`/.well-known/acme-challenge/${challenge.auth.token}`, `http://${host}`);logger.info({ challengeUrl }, "Performing ACME HTTP-01 challenge validation");try {// Notice: well, we are in a transaction, ideally we should not hold transaction and performdiff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.tsindex 7477bc032c..6f0502184d 100644--- a/backend/src/lib/config/env.ts+++ b/backend/src/lib/config/env.ts@@ -107,7 +107,16 @@ const envSchema = zROTATION_DEVELOPMENT_MODE: zodStrBool.default("false").optional(),DAILY_RESOURCE_CLEAN_UP_DEVELOPMENT_MODE: zodStrBool.default("false").optional(),ACME_DEVELOPMENT_MODE: zodStrBool.default("false").optional(),- ACME_DEVELOPMENT_HTTP01_CHALLENGE_PORT: z.coerce.number().default(8087),+ ACME_DEVELOPMENT_HTTP01_CHALLENGE_HOST_OVERRIDES: zpStr(+ z+ .string()+ .optional()+ .transform((val) => {+ if (!val) return {};+ return JSON.parse(val) as Record<string, string>;+ })+ .default("{}")+ ),// smtp optionsSMTP_HOST: zpStr(z.string().optional()),SMTP_IGNORE_TLS: zodStrBool.default("false"),