Skip to content

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

Minor fixes

Carlos Monastyrskia9bbce586aa1
diff --git a/backend/src/db/migrations/20260922154207_ca-ocsp-generation.ts b/backend/src/db/migrations/20260922154207_ca-ocsp-generation.ts
index 8247d04952..98666d1ff9 100644
--- a/backend/src/db/migrations/20260922154207_ca-ocsp-generation.ts
+++ b/backend/src/db/migrations/20260922154207_ca-ocsp-generation.ts
@@ -10,7 +10,7 @@ export async function up(knex: Knex): Promise<void> {
if (!hasColumn) {
await knex.schema.alterTable(TableName.InternalCertificateAuthority, (t) => {
- t.integer("ocspGeneration").defaultTo(0).notNullable();
+ t.bigint("ocspGeneration").defaultTo(0).notNullable();
});
}
}
diff --git a/backend/src/db/schemas/internal-certificate-authorities.ts b/backend/src/db/schemas/internal-certificate-authorities.ts
index 087941ea3d..86352bc9ec 100644
--- a/backend/src/db/schemas/internal-certificate-authorities.ts
+++ b/backend/src/db/schemas/internal-certificate-authorities.ts
@@ -34,7 +34,7 @@ export const InternalCertificateAuthoritiesSchema = z.object({
crlDistributionPointUrls: z.string().array().nullable().optional(),
disableManagedCrlDistributionPointUrl: z.boolean().default(false),
isOcspEnabled: z.boolean().default(false),
- ocspGeneration: z.number().default(0)
+ ocspGeneration: z.coerce.number().default(0)
});
export type TInternalCertificateAuthorities = z.infer<typeof InternalCertificateAuthoritiesSchema>;
diff --git a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-service.ts b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-service.ts
index 16ba5c4ed1..cf90c76ace 100644
--- a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-service.ts
+++ b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-service.ts
@@ -187,13 +187,7 @@ export const certificateAuthorityOcspServiceFactory = ({
return "good";
};
- const getOcspResponse: TCertificateAuthorityOcspServiceFactory["getOcspResponse"] = async ({ caId, requestDer }) => {
- const parsed = parseOcspRequest(requestDer);
- if (!parsed) {
- recordOcspResponseMetric({ status: "malformed_request", certStatus: "none", cache: "skipped" });
- return { response: buildOcspErrorResponse(OcspResponseStatus.MalformedRequest), maxAgeSeconds: 0 };
- }
-
+ const $resolveAuthoritativeCa = async (caId: string, entries: TParsedOcspRequestEntry[]) => {
const ca = await certificateAuthorityDAL
.findByIdWithAssociatedCa(caId, certificateAuthorityDAL.primaryNode())
.catch((error) => {
@@ -201,30 +195,38 @@ export const certificateAuthorityOcspServiceFactory = ({
throw error;
});
- if (!ca?.internalCa?.id || !ca.internalCa.isOcspEnabled || !ca.internalCa.activeCaCertId) {
- recordOcspResponseMetric({ status: "unauthorized", certStatus: "none", cache: "skipped" });
- return { response: buildOcspErrorResponse(OcspResponseStatus.Unauthorized), maxAgeSeconds: 0 };
- }
+ if (!ca?.internalCa?.id || !ca.internalCa.isOcspEnabled || !ca.internalCa.activeCaCertId) return null;
const activeCaCert = await $getActiveCaCertificate(ca.id, ca.projectId, ca.internalCa.activeCaCertId);
- if (!activeCaCert) {
- recordOcspResponseMetric({ status: "unauthorized", certStatus: "none", cache: "skipped" });
- return { response: buildOcspErrorResponse(OcspResponseStatus.Unauthorized), maxAgeSeconds: 0 };
- }
+ if (!activeCaCert) return null;
- for (const entry of parsed.entries) {
+ const issuedByThisCa = entries.every((entry) => {
const identifiers = $getIdentifiers(activeCaCert, entry.hashAlgorithmOid);
- if (
- !identifiers ||
- !identifiers.issuerNameHash.equals(entry.issuerNameHash) ||
- !identifiers.issuerKeyHash.equals(entry.issuerKeyHash)
- ) {
- recordOcspResponseMetric({ status: "unauthorized", certStatus: "none", cache: "skipped" });
- return { response: buildOcspErrorResponse(OcspResponseStatus.Unauthorized), maxAgeSeconds: 0 };
- }
+ return (
+ identifiers &&
+ identifiers.issuerNameHash.equals(entry.issuerNameHash) &&
+ identifiers.issuerKeyHash.equals(entry.issuerKeyHash)
+ );
+ });
+ if (!issuedByThisCa) return null;
+
+ return { ca, activeCaCert, generation: String(ca.internalCa.ocspGeneration) };
+ };
+
+ const getOcspResponse: TCertificateAuthorityOcspServiceFactory["getOcspResponse"] = async ({ caId, requestDer }) => {
+ const parsed = parseOcspRequest(requestDer);
+ if (!parsed) {
+ recordOcspResponseMetric({ status: "malformed_request", certStatus: "none", cache: "skipped" });
+ return { response: buildOcspErrorResponse(OcspResponseStatus.MalformedRequest), maxAgeSeconds: 0 };
+ }
+
+ const authoritative = await $resolveAuthoritativeCa(caId, parsed.entries);
+ if (!authoritative) {
+ recordOcspResponseMetric({ status: "unauthorized", certStatus: "none", cache: "skipped" });
+ return { response: buildOcspErrorResponse(OcspResponseStatus.Unauthorized), maxAgeSeconds: 0 };
}
- const generationAtStart = String(ca.internalCa.ocspGeneration);
+ const { ca, activeCaCert, generation: generationAtStart } = authoritative;
const cacheKey =
parsed.nonce || parsed.entries.length !== 1