Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Fix ACME issue on pki applications

Carlos Monastyrskia6b601ee2c73
diff --git a/backend/src/ee/services/pki-acme/pki-acme-service.ts b/backend/src/ee/services/pki-acme/pki-acme-service.ts
index 8c03dd6e56..f8d75870de 100644
--- a/backend/src/ee/services/pki-acme/pki-acme-service.ts
+++ b/backend/src/ee/services/pki-acme/pki-acme-service.ts
@@ -198,6 +198,17 @@ export const pkiAcmeServiceFactory = ({
return profile;
};
+ const resolveApplicationIdFromAccount = async (profileId: string, accountId: string): Promise<string | undefined> => {
+ const account = await acmeAccountDAL.findByProjectIdAndAccountId(profileId, accountId);
+ const accountApplicationProfileId = (account as { applicationProfileId?: string | null } | null)
+ ?.applicationProfileId;
+ if (!accountApplicationProfileId) {
+ return undefined;
+ }
+ const applicationId = await acmeAccountDAL.findApplicationIdByJunctionId(accountApplicationProfileId);
+ return applicationId ?? undefined;
+ };
+
const validateJwsPayload = async <
TSchema extends z.ZodSchema<unknown> | undefined = undefined,
T = TSchema extends z.ZodSchema<infer R> ? R : string
@@ -1407,7 +1418,8 @@ export const pkiAcmeServiceFactory = ({
orderId: string;
auditLogInfo: AuditLogInfo;
}): Promise<TAcmeResponse<string>> => {
- const profile = await validateAcmeProfile(profileId);
+ const accountApplicationId = await resolveApplicationIdFromAccount(profileId, accountId);
+ const profile = await validateAcmeProfile(profileId, accountApplicationId);
const order = await acmeOrderDAL.findByAccountAndOrderIdWithAuthorizations(accountId, orderId);
if (!order) {
throw new NotFoundError({ message: "ACME order not found" });
@@ -1545,7 +1557,8 @@ export const pkiAcmeServiceFactory = ({
challengeId: string;
auditLogInfo: AuditLogInfo;
}): Promise<TAcmeResponse<TRespondToAcmeChallengeResponse>> => {
- const profile = await validateAcmeProfile(profileId);
+ const accountApplicationId = await resolveApplicationIdFromAccount(profileId, accountId);
+ const profile = await validateAcmeProfile(profileId, accountApplicationId);
const result = await acmeChallengeDAL.findByAccountAuthAndChallengeId(accountId, authzId, challengeId);
if (!result) {
throw new NotFoundError({ message: "ACME challenge not found" });
diff --git a/backend/src/ee/services/pki-scep/pki-scep-service.ts b/backend/src/ee/services/pki-scep/pki-scep-service.ts
index 9102112d68..8004e8eb95 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-service.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-service.ts
@@ -409,7 +409,8 @@ export const pkiScepServiceFactory = ({
raPrivateKeyDer,
raCertDer,
parsed,
- clientIp
+ clientIp,
+ applicationId
});
}
}