Skip to content

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

Address greptile comments

Carlos Monastyrskic272058b4f2d
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index 5b7dfd3ba1..bf42bba26f 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -867,19 +867,33 @@ what an anonymous caller can cost us.
zero-stripped `serialNumber`, and `$resolveStatuses` queries both. Querying one silently answers
`unknown` for every certificate whose serial starts with a zero byte, revoked ones included.
- **Every read on the revocation path goes to a primary, in Redis and in Postgres.** `keyStore.getItem`
- and `ormify().find` both default to a replica. Under lag either one re-caches a pre-revocation `good`
- for the full validity window. Use `getItemPrimary` and pass `certificateDAL.primaryNode()` as the `tx`.
-- **The cache must be reaped wherever a status can change**: revoke, delete, and toggling the flag. A miss
- leaves a revoked certificate reading `good` for up to an hour. Only single-certID responses are cached;
- multi-certID requests are answered but never cached, so there is one key scheme to invalidate.
+ and `ormify().find` both default to a replica, and so does `findByIdWithAssociatedCa`. Under lag any of
+ them re-caches a pre-revocation `good` for the full validity window, or answers for a CA whose OCSP was
+ just switched off. Use `getItemPrimary` and pass a `primaryNode()` as the `tx`.
+- **Invalidation is a Postgres counter, not a Redis write.** `internal_certificate_authorities.ocspGeneration`
+ is bumped in the *same transaction* as the write that changes a status: the revoke, the single delete, and
+ the bulk cleanup delete. Each cached entry records the generation it was signed under and a read rejects a
+ mismatch, so nothing has to delete a key and a Redis outage cannot leave a revoked certificate reading
+ `good`. The responder already reads the CA row from the primary every request, so comparing it is free.
+ A new path that deletes or revokes a certificate must bump it too, or it will serve a stale `good` for up
+ to an hour. Only single-certID responses are cached; multi-certID requests are answered but never cached.
+ Do not reintroduce a best-effort invalidation call after the commit: that is exactly the shape that failed
+ review, because a failure there is unrecoverable and silent.
- **Concurrent misses coalesce into one signing.** `inFlightResponses` keys on the cache key plus the
- generation counter. The generation is what stops a request arriving after a revoke from joining a flight
+ generation. The generation is what stops a request arriving after a revoke from joining a flight
that began before it. Nonced requests are exempt for free, because their cache key is `null`.
+- **A nonce is an OCTET STRING, and an extnValue that is not one is rejected.** The response always
+ re-encodes the nonce wrapped, so accepting a raw inner value would sign an echo that can never match what
+ the client sent. `parseOcspRequest` returns `null`, which the service answers as `malformedRequest`.
- **Never take the hash OID out of a CertID without checking `OCSP_HASH_NAME_BY_OID` first.** An OID is an
unbounded dotted-decimal string and it keys the per-CA issuer-hash memo, so an unvalidated one is
unbounded attacker-controlled heap.
-- **Signing is concurrency-capped globally and per CA and sheds with `tryLater`.** The per-CA tier stops
- one tenant's traffic shedding everyone else's. Both are per process, so the rate limiter is the outer
+- **Signing is capped three ways and sheds with `tryLater`**: globally, per CA, and in aggregate across
+ every CA (`OCSP_SIGNING_MAX_TOTAL_IN_FLIGHT`, checked before a per-CA limiter is created or entered). The
+ per-CA tier stops one tenant's traffic shedding everyone else's, but on its own it multiplies how many
+ requests are parked at once, because a caller choosing to spray across many valid CA ids gets a fresh
+ queue per id. The aggregate cap is what bounds that, and it is deliberately far above any single CA's
+ own limit so the fairness the per-CA tier buys is preserved. Both are per process, so the rate limiter is the outer
bound, and it is only registered under `isProductionMode && isCloud`.
- **Do not log per request on this path.** The endpoint is unauthenticated and the rate limiter is only
registered under `isProductionMode && isCloud`, so on self-hosted an anonymous caller sets the log
diff --git a/backend/src/db/migrations/20260922154207_ca-ocsp-generation.ts b/backend/src/db/migrations/20260922154207_ca-ocsp-generation.ts
new file mode 100644
index 0000000000..8247d04952
--- /dev/null
+++ b/backend/src/db/migrations/20260922154207_ca-ocsp-generation.ts
@@ -0,0 +1,29 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ const hasTable = await knex.schema.hasTable(TableName.InternalCertificateAuthority);
+ if (!hasTable) return;
+
+ const hasColumn = await knex.schema.hasColumn(TableName.InternalCertificateAuthority, "ocspGeneration");
+
+ if (!hasColumn) {
+ await knex.schema.alterTable(TableName.InternalCertificateAuthority, (t) => {
+ t.integer("ocspGeneration").defaultTo(0).notNullable();
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ const hasTable = await knex.schema.hasTable(TableName.InternalCertificateAuthority);
+ if (!hasTable) return;
+
+ const hasColumn = await knex.schema.hasColumn(TableName.InternalCertificateAuthority, "ocspGeneration");
+
+ if (hasColumn) {
+ await knex.schema.alterTable(TableName.InternalCertificateAuthority, (t) => {
+ t.dropColumn("ocspGeneration");
+ });
+ }
+}
diff --git a/backend/src/db/schemas/internal-certificate-authorities.ts b/backend/src/db/schemas/internal-certificate-authorities.ts
index d1895efdca..087941ea3d 100644
--- a/backend/src/db/schemas/internal-certificate-authorities.ts
+++ b/backend/src/db/schemas/internal-certificate-authorities.ts
@@ -33,7 +33,8 @@ export const InternalCertificateAuthoritiesSchema = z.object({
lastRenewalAt: z.date().nullable().optional(),
crlDistributionPointUrls: z.string().array().nullable().optional(),
disableManagedCrlDistributionPointUrl: z.boolean().default(false),
- isOcspEnabled: z.boolean().default(false)
+ isOcspEnabled: z.boolean().default(false),
+ ocspGeneration: z.number().default(0)
});
export type TInternalCertificateAuthorities = z.infer<typeof InternalCertificateAuthoritiesSchema>;
diff --git a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-coalescing.test.ts b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-coalescing.test.ts
index e043436bb5..503d705a23 100644
--- a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-coalescing.test.ts
+++ b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-coalescing.test.ts
@@ -30,15 +30,12 @@ const buildKeyStore = () => {
store.set(key, value);
return "OK" as const;
}),
- deleteItemsByKeyIn: vi.fn(async (keys: string[]) => {
- keys.forEach((key) => store.delete(key));
- return keys.length;
- }),
incrementSeededWithExpiry: vi.fn(async (key: string, seed: number) => {
const next = store.has(key) ? Number(store.get(key)) + 1 : seed + 1;
store.set(key, String(next));
return next;
- })
+ }),
+ store
};
};
@@ -86,12 +83,15 @@ const buildHarness = async () => {
const keyStore = buildKeyStore();
+ let ocspGeneration = 0;
+
const service = certificateAuthorityOcspServiceFactory({
certificateAuthorityDAL: {
+ primaryNode: vi.fn(() => undefined),
findByIdWithAssociatedCa: vi.fn(async () => ({
id: caId,
projectId: "project-1",
- internalCa: { id: "internal-1", isOcspEnabled: true, activeCaCertId: caCertId }
+ internalCa: { id: "internal-1", isOcspEnabled: true, activeCaCertId: caCertId, ocspGeneration }
}))
} as never,
certificateAuthorityCertDAL: {
@@ -133,8 +133,13 @@ const buildHarness = async () => {
service,
buildRequestDer,
keyStore,
+ cacheKeys: () => [...keyStore.store.keys()].filter((k) => k.startsWith("ocsp-response:")),
+ storeHas: (cacheKeys: string[]) => cacheKeys.length > 0 && cacheKeys.every((k) => keyStore.store.has(k)),
getSignCount: () => signCount,
- releaseGate: () => releaseGate()
+ releaseGate: () => releaseGate(),
+ revoke: () => {
+ ocspGeneration += 1;
+ }
};
};
@@ -209,7 +214,7 @@ describe("revocation during an in-flight signing", () => {
setTimeout(resolve, 20);
});
- await harness.service.invalidateCachedResponse({ caId: harness.caId, serialNumber: "01" });
+ harness.revoke();
const follower = harness.service.getOcspResponse({ caId: harness.caId, requestDer });
@@ -224,3 +229,26 @@ describe("revocation during an in-flight signing", () => {
expect(followerResult.response.equals(leaderResult.response)).toBe(false);
});
});
+
+describe("cache coherence after revocation", () => {
+ it("should not serve a cached good once the generation moves, even with nothing deleting the key", async () => {
+ const harness: THarness = await buildHarness();
+ const requestDer = await harness.buildRequestDer();
+
+ harness.releaseGate();
+ const first = await harness.service.getOcspResponse({ caId: harness.caId, requestDer });
+ expect(harness.getSignCount()).toBe(1);
+
+ const second = await harness.service.getOcspResponse({ caId: harness.caId, requestDer });
+ expect(harness.getSignCount()).toBe(1);
+ expect(second.response.equals(first.response)).toBe(true);
+
+ // the cached entry is deliberately left in the store: only the generation moved
+ harness.revoke();
+ expect(harness.storeHas(harness.cacheKeys())).toBe(true);
+
+ const third = await harness.service.getOcspResponse({ caId: harness.caId, requestDer });
+ expect(harness.getSignCount()).toBe(2);
+ expect(third.response.equals(first.response)).toBe(false);
+ });
+});
diff --git a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-enums.ts b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-enums.ts
index f597a037ae..1799aaeda2 100644
--- a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-enums.ts
+++ b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-enums.ts
@@ -32,12 +32,12 @@ export const OCSP_MAX_SERIAL_HEX_LENGTH = 42;
export const OCSP_MAX_NONCE_BYTES = 32;
export const OCSP_RESPONSE_VALIDITY_SECONDS = 60 * 60;
export const OCSP_UNKNOWN_RESPONSE_VALIDITY_SECONDS = 60;
-export const OCSP_GENERATION_TTL_SECONDS = 24 * 60 * 60;
export const STORED_SERIAL_HEX_LENGTH = 40;
export const OCSP_MAX_CONCURRENT_SIGNATURES = 8;
export const OCSP_MAX_CONCURRENT_SIGNATURES_PER_CA = 4;
export const OCSP_SIGNING_QUEUE_TIMEOUT_MS = 5_000;
export const OCSP_SIGNING_MAX_QUEUE_DEPTH = 64;
export const OCSP_MAX_TRACKED_CA_LIMITERS = 256;
+export const OCSP_SIGNING_MAX_TOTAL_IN_FLIGHT = 512;
export const OCSP_MAX_CACHED_CA_CERTIFICATES = 256;
export const OCSP_SATURATION_LOG_INTERVAL_MS = 10_000;
diff --git a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-fns.test.ts b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-fns.test.ts
index 134b9e8866..80075f7e25 100644
--- a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-fns.test.ts
+++ b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-fns.test.ts
@@ -355,6 +355,52 @@ describe("nonce extension hardening", () => {
});
});
+describe("nonce encoding", () => {
+ const buildWithNonceExtension = (extnValue: Uint8Array) => {
+ const certId = new asn1js.Sequence({
+ value: [
+ new asn1js.Sequence({
+ value: [new asn1js.ObjectIdentifier({ value: "1.3.14.3.2.26" }), new asn1js.Null()]
+ }),
+ new asn1js.OctetString({ valueHex: new Uint8Array(20).fill(0xaa) }),
+ new asn1js.OctetString({ valueHex: new Uint8Array(20).fill(0xbb) }),
+ new asn1js.Integer({ value: 1 })
+ ]
+ });
+ const extensions = new asn1js.Constructed({
+ idBlock: { tagClass: 3, tagNumber: 2 },
+ value: [
+ new asn1js.Sequence({
+ value: [
+ new asn1js.Sequence({
+ value: [
+ new asn1js.ObjectIdentifier({ value: OCSP_NONCE_OID }),
+ new asn1js.OctetString({ valueHex: extnValue })
+ ]
+ })
+ ]
+ })
+ ]
+ });
+ const tbs = new asn1js.Sequence({
+ value: [new asn1js.Sequence({ value: [new asn1js.Sequence({ value: [certId] })] }), extensions]
+ });
+ return Buffer.from(new asn1js.Sequence({ value: [tbs] }).toBER(false));
+ };
+
+ it("should accept a nonce wrapped as an OCTET STRING, which is what RFC 6960 defines", () => {
+ const wrapped = new Uint8Array(new asn1js.OctetString({ valueHex: new Uint8Array(16).fill(0xab) }).toBER(false));
+ const parsed = parseOcspRequest(buildWithNonceExtension(wrapped));
+
+ expect(parsed?.nonce?.equals(Buffer.alloc(16, 0xab))).toBe(true);
+ });
+
+ it("should reject an unwrapped nonce rather than signing a response it can never match", () => {
+ // the response re-encodes the nonce wrapped, so echoing raw bytes would not match the request
+ expect(parseOcspRequest(buildWithNonceExtension(new Uint8Array(16).fill(0xab)))).toBeNull();
+ });
+});
+
describe("hash algorithm allowlist", () => {
const buildRequestWithOid = (oid: string) => {
const certId = new asn1js.Sequence({
diff --git a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-fns.ts b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-fns.ts
index 0dab1f9a1c..4b23abb3d9 100644
--- a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-fns.ts
+++ b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-fns.ts
@@ -122,11 +122,8 @@ export const parseOcspRequest = (der: Buffer): TParsedOcspRequest | null => {
if (nonceExtension) {
const rawExtnValue = new Uint8Array(nonceExtension.extnValue.valueBlock.valueHexView);
const decoded = asn1js.fromBER(toArrayBuffer(rawExtnValue));
- if (decoded.offset !== -1 && !(decoded.result instanceof asn1js.OctetString)) return null;
- const candidate =
- decoded.offset === -1
- ? Buffer.from(rawExtnValue)
- : Buffer.from((decoded.result as asn1js.OctetString).valueBlock.valueHexView);
+ if (decoded.offset === -1 || !(decoded.result instanceof asn1js.OctetString)) return null;
+ const candidate = Buffer.from(decoded.result.valueBlock.valueHexView);
if (candidate.length === 0 || candidate.length > OCSP_MAX_NONCE_BYTES) return null;
nonce = candidate;
diff --git a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-limiter.test.ts b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-limiter.test.ts
index 9f0f6ce0eb..d7f9c6def8 100644
--- a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-limiter.test.ts
+++ b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-limiter.test.ts
@@ -113,7 +113,8 @@ describe("createOcspSigningLimiterRegistry", () => {
perCaLimit: 2,
maxWaitMs: 5000,
maxQueueDepth: 64,
- maxTrackedCas: 8
+ maxTrackedCas: 8,
+ maxTotalInFlight: 512
});
const gate = deferred();
let noisyPeak = 0;
@@ -148,7 +149,8 @@ describe("createOcspSigningLimiterRegistry", () => {
perCaLimit: 2,
maxWaitMs: 1000,
maxQueueDepth: 64,
- maxTrackedCas: 3
+ maxTrackedCas: 3,
+ maxTotalInFlight: 512
});
for (let i = 0; i < 10; i += 1) {
@@ -159,3 +161,45 @@ describe("createOcspSigningLimiterRegistry", () => {
expect(registry.getTrackedCaCount()).toBeLessThanOrEqual(4);
});
});
+
+describe("aggregate admission across CAs", () => {
+ it("should shed once total in-flight reaches the cap, however many CAs the traffic is spread over", async () => {
+ const registry = createOcspSigningLimiterRegistry({
+ globalLimit: 8,
+ perCaLimit: 4,
+ maxWaitMs: 60_000,
+ maxQueueDepth: 64,
+ maxTrackedCas: 256,
+ maxTotalInFlight: 32
+ });
+
+ let release!: () => void;
+ const gate = new Promise<void>((resolve) => {
+ release = resolve;
+ });
+
+ const inFlight: Promise<unknown>[] = [];
+ for (let ca = 0; ca < 64; ca += 1) {
+ for (let i = 0; i < 10; i += 1) {
+ inFlight.push(
+ registry.runForCa(`ca-${ca}`, async () => {
+ await gate;
+ })
+ );
+ }
+ }
+
+ await new Promise((resolve) => {
+ setTimeout(resolve, 50);
+ });
+
+ expect(registry.getTotalInFlight()).toBe(32);
+ expect(registry.getTrackedCaCount()).toBeLessThanOrEqual(32);
+
+ release();
+ const results = await Promise.all(inFlight);
+
+ expect(results.filter((result) => result === null).length).toBeGreaterThan(0);
+ expect(registry.getTotalInFlight()).toBe(0);
+ });
+});
diff --git a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-limiter.ts b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-limiter.ts
index 2ba770d83b..d7bcbf4b1a 100644
--- a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-limiter.ts
+++ b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-limiter.ts
@@ -55,16 +55,19 @@ export const createOcspSigningLimiterRegistry = ({
perCaLimit,
maxWaitMs,
maxQueueDepth,
- maxTrackedCas
+ maxTrackedCas,
+ maxTotalInFlight
}: {
globalLimit: number;
perCaLimit: number;
maxWaitMs: number;
maxQueueDepth: number;
maxTrackedCas: number;
+ maxTotalInFlight: number;
}) => {
const globalLimiter = createOcspSigningLimiter(globalLimit, maxWaitMs, maxQueueDepth);
const perCaLimiters = new Map<string, TOcspSigningLimiter>();
+ let totalInFlight = 0;
const pruneIdle = () => {
if (perCaLimiters.size <= maxTrackedCas) return;
@@ -75,14 +78,21 @@ export const createOcspSigningLimiterRegistry = ({
};
const runForCa = async <T>(caId: string, fn: () => Promise<T>): Promise<T | null> => {
- let caLimiter = perCaLimiters.get(caId);
- if (!caLimiter) {
- pruneIdle();
- caLimiter = createOcspSigningLimiter(perCaLimit, maxWaitMs, maxQueueDepth);
- perCaLimiters.set(caId, caLimiter);
- }
+ if (totalInFlight >= maxTotalInFlight) return null;
- return caLimiter.run(() => globalLimiter.run(fn));
+ totalInFlight += 1;
+ try {
+ let caLimiter = perCaLimiters.get(caId);
+ if (!caLimiter) {
+ pruneIdle();
+ caLimiter = createOcspSigningLimiter(perCaLimit, maxWaitMs, maxQueueDepth);
+ perCaLimiters.set(caId, caLimiter);
+ }
+
+ return await caLimiter.run(() => globalLimiter.run(fn));
+ } finally {
+ totalInFlight -= 1;
+ }
};
return {
@@ -90,7 +100,8 @@ export const createOcspSigningLimiterRegistry = ({
getGlobalActiveCount: () => globalLimiter.getActiveCount(),
getGlobalQueueDepth: () => globalLimiter.getQueueDepth(),
getCaQueueDepth: (caId: string) => perCaLimiters.get(caId)?.getQueueDepth() ?? 0,
- getTrackedCaCount: () => perCaLimiters.size
+ getTrackedCaCount: () => perCaLimiters.size,
+ getTotalInFlight: () => totalInFlight
};
};
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 7555f80951..16ba5c4ed1 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
@@ -21,8 +21,6 @@ import { TProjectDALFactory } from "@app/services/project/project-dal";
import { getProjectKmsCertificateKeyId } from "@app/services/project/project-fns";
import {
- OCSP_GENERATION_TTL_SECONDS,
- OCSP_HASH_NAME_BY_OID,
OCSP_MAX_CACHED_CA_CERTIFICATES,
OCSP_MAX_CONCURRENT_SIGNATURES,
OCSP_MAX_CONCURRENT_SIGNATURES_PER_CA,
@@ -30,6 +28,7 @@ import {
OCSP_RESPONSE_VALIDITY_SECONDS,
OCSP_SATURATION_LOG_INTERVAL_MS,
OCSP_SIGNING_MAX_QUEUE_DEPTH,
+ OCSP_SIGNING_MAX_TOTAL_IN_FLIGHT,
OCSP_SIGNING_QUEUE_TIMEOUT_MS,
OCSP_UNKNOWN_RESPONSE_VALIDITY_SECONDS,
OcspCertStatus,
@@ -52,27 +51,21 @@ import {
} from "./certificate-authority-ocsp-types";
type TCertificateAuthorityOcspServiceFactoryDep = {
- certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory, "findByIdWithAssociatedCa">;
+ certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory, "findByIdWithAssociatedCa" | "primaryNode">;
certificateAuthorityCertDAL: Pick<TCertificateAuthorityCertDALFactory, "findById">;
certificateAuthoritySecretDAL: Pick<TCertificateAuthoritySecretDALFactory, "findOne">;
certificateDAL: Pick<TCertificateDALFactory, "find" | "primaryNode">;
projectDAL: Pick<TProjectDALFactory, "findById" | "findOne" | "updateById" | "transaction">;
kmsService: Pick<TKmsServiceFactory, "decryptWithKmsKey" | "generateKmsKey">;
hsmConnectorService: Pick<THsmConnectorServiceFactory, "sign">;
- keyStore: Pick<
- TKeyStoreFactory,
- "getItemPrimary" | "setItemWithExpiry" | "deleteItemsByKeyIn" | "incrementSeededWithExpiry"
- >;
+ keyStore: Pick<TKeyStoreFactory, "getItemPrimary" | "setItemWithExpiry">;
};
const OCSP_CACHE_PREFIX = "ocsp-response";
-const OCSP_GENERATION_PREFIX = "ocsp-generation";
const buildCacheKey = (caCertId: string, hashAlgorithmOid: string, serialNumber: string) =>
`${OCSP_CACHE_PREFIX}:${caCertId}:${hashAlgorithmOid}:${serialNumber}`;
-const buildGenerationKey = (caId: string) => `${OCSP_GENERATION_PREFIX}:${caId}`;
-
type TCaOcspIdentifiers = ReturnType<typeof getCaOcspIdentifiers>;
type TResolvedCaCertificate = {
@@ -96,7 +89,8 @@ const signingLimiters = createOcspSigningLimiterRegistry({
perCaLimit: OCSP_MAX_CONCURRENT_SIGNATURES_PER_CA,
maxWaitMs: OCSP_SIGNING_QUEUE_TIMEOUT_MS,
maxQueueDepth: OCSP_SIGNING_MAX_QUEUE_DEPTH,
- maxTrackedCas: OCSP_MAX_TRACKED_CA_LIMITERS
+ maxTrackedCas: OCSP_MAX_TRACKED_CA_LIMITERS,
+ maxTotalInFlight: OCSP_SIGNING_MAX_TOTAL_IN_FLIGHT
});
export const certificateAuthorityOcspServiceFactory = ({
@@ -200,10 +194,12 @@ export const certificateAuthorityOcspServiceFactory = ({
return { response: buildOcspErrorResponse(OcspResponseStatus.MalformedRequest), maxAgeSeconds: 0 };
}
- const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(caId).catch((error) => {
- if (error instanceof NotFoundError) return null;
- throw error;
- });
+ const ca = await certificateAuthorityDAL
+ .findByIdWithAssociatedCa(caId, certificateAuthorityDAL.primaryNode())
+ .catch((error) => {
+ if (error instanceof NotFoundError) return null;
+ throw error;
+ });
if (!ca?.internalCa?.id || !ca.internalCa.isOcspEnabled || !ca.internalCa.activeCaCertId) {
recordOcspResponseMetric({ status: "unauthorized", certStatus: "none", cache: "skipped" });
@@ -228,8 +224,7 @@ export const certificateAuthorityOcspServiceFactory = ({
}
}
- const generationKey = buildGenerationKey(ca.id);
- const generationAtStart = (await keyStore.getItemPrimary(generationKey)) ?? "0";
+ const generationAtStart = String(ca.internalCa.ocspGeneration);
const cacheKey =
parsed.nonce || parsed.entries.length !== 1
@@ -239,13 +234,14 @@ export const certificateAuthorityOcspServiceFactory = ({
if (cacheKey) {
const cached = await keyStore.getItemPrimary(cacheKey);
if (cached) {
- const { der, expiresAt, certStatus } = JSON.parse(cached) as {
+ const { der, expiresAt, certStatus, generation } = JSON.parse(cached) as {
der: string;
expiresAt: number;
certStatus: TOcspCertStatusLabel;
+ generation: string;
};
const remaining = Math.floor((expiresAt - Date.now()) / 1000);
- if (remaining > 0) {
+ if (remaining > 0 && generation === generationAtStart) {
recordOcspResponseMetric({ status: "successful", certStatus, cache: "hit" });
return { response: Buffer.from(der, "base64"), maxAgeSeconds: remaining };
}
@@ -315,18 +311,16 @@ export const certificateAuthorityOcspServiceFactory = ({
});
if (cacheKey) {
- const generationNow = (await keyStore.getItemPrimary(generationKey)) ?? "0";
- if (generationNow === generationAtStart) {
- await keyStore.setItemWithExpiry(
- cacheKey,
- validitySeconds,
- JSON.stringify({
- der: response.toString("base64"),
- expiresAt: nextUpdate.getTime(),
- certStatus: resolvedCertStatus
- })
- );
- }
+ await keyStore.setItemWithExpiry(
+ cacheKey,
+ validitySeconds,
+ JSON.stringify({
+ der: response.toString("base64"),
+ expiresAt: nextUpdate.getTime(),
+ generation: generationAtStart,
+ certStatus: resolvedCertStatus
+ })
+ );
}
return {
@@ -357,20 +351,5 @@ export const certificateAuthorityOcspServiceFactory = ({
}
};
- const invalidateCachedResponse: TCertificateAuthorityOcspServiceFactory["invalidateCachedResponse"] = async ({
- caId,
- serialNumber
- }) => {
- const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(caId);
- const activeCaCertId = ca?.internalCa?.activeCaCertId;
- if (!activeCaCertId) return;
-
- const normalized = normalizeSerialNumber(serialNumber);
- const keys = Object.keys(OCSP_HASH_NAME_BY_OID).map((oid) => buildCacheKey(activeCaCertId, oid, normalized));
-
- await keyStore.incrementSeededWithExpiry(buildGenerationKey(caId), Date.now(), OCSP_GENERATION_TTL_SECONDS);
- await keyStore.deleteItemsByKeyIn(keys);
- };
-
- return { getOcspResponse, invalidateCachedResponse };
+ return { getOcspResponse };
};
diff --git a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-types.ts b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-types.ts
index 108a40b4ab..4060eb6553 100644
--- a/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-types.ts
+++ b/backend/src/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-types.ts
@@ -23,11 +23,6 @@ export type TGetOcspResponseDTO = {
requestDer: Buffer;
};
-export type TInvalidateOcspCacheDTO = {
- caId: string;
- serialNumber: string;
-};
-
export type TOcspResponseResult = {
response: Buffer;
maxAgeSeconds: number;
@@ -35,5 +30,4 @@ export type TOcspResponseResult = {
export type TCertificateAuthorityOcspServiceFactory = {
getOcspResponse: (dto: TGetOcspResponseDTO) => Promise<TOcspResponseResult>;
- invalidateCachedResponse: (dto: TInvalidateOcspCacheDTO) => Promise<void>;
};
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 7f34ce05f9..298223a989 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2947,6 +2947,7 @@ export const registerRoutes = async (
certificateCleanupConfigDAL,
certificateDAL,
certificateRequestDAL,
+ internalCertificateAuthorityDAL,
auditLogService,
telemetryService
});
@@ -3649,7 +3650,7 @@ export const registerRoutes = async (
licenseService,
usageMeteringService,
hsmConnectorService,
- certificateAuthorityOcspService
+ internalCertificateAuthorityDAL
});
const godaddyCaFns = GoDaddyCertificateAuthorityFns({
diff --git a/backend/src/services/certificate-authority/certificate-authority-dal.ts b/backend/src/services/certificate-authority/certificate-authority-dal.ts
index d8bebc6b34..2fa7631ef4 100644
--- a/backend/src/services/certificate-authority/certificate-authority-dal.ts
+++ b/backend/src/services/certificate-authority/certificate-authority-dal.ts
@@ -59,7 +59,8 @@ export const certificateAuthorityDALFactory = (db: TDbClient) => {
.ref("disableManagedCrlDistributionPointUrl")
.withSchema(TableName.InternalCertificateAuthority)
.as("internalDisableManagedCrlDistributionPointUrl"),
- db.ref("isOcspEnabled").withSchema(TableName.InternalCertificateAuthority).as("internalIsOcspEnabled")
+ db.ref("isOcspEnabled").withSchema(TableName.InternalCertificateAuthority).as("internalIsOcspEnabled"),
+ db.ref("ocspGeneration").withSchema(TableName.InternalCertificateAuthority).as("internalOcspGeneration")
)
.select(
db.ref("id").withSchema(TableName.ExternalCertificateAuthority).as("externalCaId"),
@@ -97,7 +98,8 @@ export const certificateAuthorityDALFactory = (db: TDbClient) => {
activeCaCertId: result.internalActiveCaCertId,
crlDistributionPointUrls: result.internalCrlDistributionPointUrls ?? [],
disableManagedCrlDistributionPointUrl: result.internalDisableManagedCrlDistributionPointUrl ?? false,
- isOcspEnabled: result.internalIsOcspEnabled ?? false
+ isOcspEnabled: result.internalIsOcspEnabled ?? false,
+ ocspGeneration: result.internalOcspGeneration ?? 0
}
: undefined,
externalCa: result
@@ -155,7 +157,8 @@ export const certificateAuthorityDALFactory = (db: TDbClient) => {
.ref("disableManagedCrlDistributionPointUrl")
.withSchema(TableName.InternalCertificateAuthority)
.as("internalDisableManagedCrlDistributionPointUrl"),
- db.ref("isOcspEnabled").withSchema(TableName.InternalCertificateAuthority).as("internalIsOcspEnabled")
+ db.ref("isOcspEnabled").withSchema(TableName.InternalCertificateAuthority).as("internalIsOcspEnabled"),
+ db.ref("ocspGeneration").withSchema(TableName.InternalCertificateAuthority).as("internalOcspGeneration")
)
.select(
db.ref("id").withSchema(TableName.ExternalCertificateAuthority).as("externalCaId"),
@@ -196,7 +199,8 @@ export const certificateAuthorityDALFactory = (db: TDbClient) => {
activeCaCertId: result.internalActiveCaCertId,
crlDistributionPointUrls: result.internalCrlDistributionPointUrls ?? [],
disableManagedCrlDistributionPointUrl: result.internalDisableManagedCrlDistributionPointUrl ?? false,
- isOcspEnabled: result.internalIsOcspEnabled ?? false
+ isOcspEnabled: result.internalIsOcspEnabled ?? false,
+ ocspGeneration: result.internalOcspGeneration ?? 0
}
: undefined,
externalCa: result
@@ -295,7 +299,8 @@ export const certificateAuthorityDALFactory = (db: TDbClient) => {
.ref("disableManagedCrlDistributionPointUrl")
.withSchema(TableName.InternalCertificateAuthority)
.as("internalDisableManagedCrlDistributionPointUrl"),
- db.ref("isOcspEnabled").withSchema(TableName.InternalCertificateAuthority).as("internalIsOcspEnabled")
+ db.ref("isOcspEnabled").withSchema(TableName.InternalCertificateAuthority).as("internalIsOcspEnabled"),
+ db.ref("ocspGeneration").withSchema(TableName.InternalCertificateAuthority).as("internalOcspGeneration")
)
.select(
db.ref("id").withSchema(TableName.ExternalCertificateAuthority).as("externalCaId"),
@@ -352,7 +357,8 @@ export const certificateAuthorityDALFactory = (db: TDbClient) => {
activeCaCertId: ca.internalActiveCaCertId,
crlDistributionPointUrls: ca.internalCrlDistributionPointUrls ?? [],
disableManagedCrlDistributionPointUrl: ca.internalDisableManagedCrlDistributionPointUrl ?? false,
- isOcspEnabled: ca.internalIsOcspEnabled ?? false
+ isOcspEnabled: ca.internalIsOcspEnabled ?? false,
+ ocspGeneration: ca.internalOcspGeneration ?? 0
}
: undefined,
externalCa: ca
@@ -407,8 +413,11 @@ export const certificateAuthorityDALFactory = (db: TDbClient) => {
}
};
+ const primaryNode = () => db.primaryNode();
+
return {
...caOrm,
+ primaryNode,
findWithAssociatedCa,
buildCertificateChain,
findByIdWithAssociatedCa,
diff --git a/backend/src/services/certificate-cleanup/certificate-cleanup-queue.ts b/backend/src/services/certificate-cleanup/certificate-cleanup-queue.ts
index 7e651415d4..42ac6d5e57 100644
--- a/backend/src/services/certificate-cleanup/certificate-cleanup-queue.ts
+++ b/backend/src/services/certificate-cleanup/certificate-cleanup-queue.ts
@@ -10,6 +10,7 @@ import { QueueJobs } from "@app/queue";
import { ActorType } from "@app/services/auth/auth-type";
import { TCertificateDALFactory } from "../certificate/certificate-dal";
+import { TInternalCertificateAuthorityDALFactory } from "../certificate-authority/internal/internal-certificate-authority-dal";
import { TCertificateRequestDALFactory } from "../certificate-request/certificate-request-dal";
import { TTelemetryServiceFactory } from "../telemetry/telemetry-service";
import { PostHogEventTypes } from "../telemetry/telemetry-types";
@@ -22,6 +23,7 @@ type TCertificateCleanupQueueFactoryDep = {
certificateCleanupConfigDAL: TCertificateCleanupConfigDALFactory;
certificateDAL: Pick<TCertificateDALFactory, "delete">;
certificateRequestDAL: Pick<TCertificateRequestDALFactory, "delete">;
+ internalCertificateAuthorityDAL: Pick<TInternalCertificateAuthorityDALFactory, "update">;
auditLogService: Pick<TAuditLogServiceFactory, "createAuditLog">;
telemetryService: Pick<TTelemetryServiceFactory, "sendPostHogEvents">;
};
@@ -34,6 +36,7 @@ export const certificateCleanupQueueFactory = ({
certificateCleanupConfigDAL,
certificateDAL,
certificateRequestDAL,
+ internalCertificateAuthorityDAL,
auditLogService,
telemetryService
}: TCertificateCleanupQueueFactoryDep) => {
@@ -116,7 +119,18 @@ export const certificateCleanupQueueFactory = ({
try {
const deleted = await certificateCleanupConfigDAL.transaction(async (tx) => {
await certificateRequestDAL.delete({ $in: { certificateId: idsToDelete } }, tx);
- return certificateDAL.delete({ $in: { id: idsToDelete } }, tx);
+ const removed = await certificateDAL.delete({ $in: { id: idsToDelete } }, tx);
+
+ const caIds = [...new Set(removed.map((cert) => cert.caId).filter(Boolean))] as string[];
+ if (caIds.length > 0) {
+ await internalCertificateAuthorityDAL.update(
+ { $in: { caId: caIds } },
+ { $incr: { ocspGeneration: 1 } },
+ tx
+ );
+ }
+
+ return removed;
});
deletedCount += deleted.length;
diff --git a/backend/src/services/certificate-v3/certificate-v3-service.test.ts b/backend/src/services/certificate-v3/certificate-v3-service.test.ts
index cc6dfab468..44ac72040e 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.test.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.test.ts
@@ -431,7 +431,8 @@ describe("CertificateV3Service", () => {
caId: "ca-123",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
},
name: "Test CA",
status: "ACTIVE",
@@ -496,7 +497,8 @@ describe("CertificateV3Service", () => {
caId: "ca-123",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
}
}
};
@@ -607,7 +609,8 @@ describe("CertificateV3Service", () => {
caId: "ca-123",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
},
name: "Test CA",
status: "ACTIVE",
@@ -952,7 +955,8 @@ describe("CertificateV3Service", () => {
caId: "ca-123",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
},
name: "Test CA",
status: "ACTIVE",
@@ -1068,7 +1072,8 @@ describe("CertificateV3Service", () => {
caId: "ca-123",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
}
}
};
@@ -1239,7 +1244,8 @@ describe("CertificateV3Service", () => {
caId: "ca-123",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
},
name: "Test CA",
status: "ACTIVE",
@@ -1287,7 +1293,8 @@ describe("CertificateV3Service", () => {
caId: "ca-123",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
}
}
};
@@ -1704,7 +1711,8 @@ describe("CertificateV3Service", () => {
caId: "ca-1",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
}
};
@@ -1878,7 +1886,8 @@ describe("CertificateV3Service", () => {
caId: "ca-1",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
}
};
@@ -2052,7 +2061,8 @@ describe("CertificateV3Service", () => {
caId: "ca-1",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
}
};
@@ -2226,7 +2236,8 @@ describe("CertificateV3Service", () => {
caId: "ca-1",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
}
};
@@ -2468,7 +2479,8 @@ describe("CertificateV3Service", () => {
serialNumber: "123456789",
crlDistributionPointUrls: [],
disableManagedCrlDistributionPointUrl: false,
- isOcspEnabled: false
+ isOcspEnabled: false,
+ ocspGeneration: 0
}
};
diff --git a/backend/src/services/certificate/certificate-service.ts b/backend/src/services/certificate/certificate-service.ts
index 3ecd7919b1..c1ea144a51 100644
--- a/backend/src/services/certificate/certificate-service.ts
+++ b/backend/src/services/certificate/certificate-service.ts
@@ -5,7 +5,6 @@ import * as x509 from "@peculiar/x509";
import { ActionProjectType, ProjectMembershipRole, ResourceType } from "@app/db/schemas";
import { TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";
import { TCertificateAuthorityCrlDALFactory } from "@app/ee/services/certificate-authority-crl/certificate-authority-crl-dal";
-import { TCertificateAuthorityOcspServiceFactory } from "@app/ee/services/certificate-authority-ocsp/certificate-authority-ocsp-types";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
@@ -74,6 +73,7 @@ import {
getCaCertChains,
rebuildCaCrl
} from "../certificate-authority/certificate-authority-fns";
+import { TInternalCertificateAuthorityDALFactory } from "../certificate-authority/internal/internal-certificate-authority-dal";
import { parseImportedCustomExtensions } from "../certificate-common/certificate-extension-fns";
import {
calculateFinalRenewBeforeDays,
@@ -161,7 +161,7 @@ type TCertificateServiceFactoryDep = {
keyStore: Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry" | "deleteItem">;
usageMeteringService: Pick<TUsageMeteringServiceFactory, "emitForProject">;
hsmConnectorService: Pick<THsmConnectorServiceFactory, "sign">;
- certificateAuthorityOcspService: Pick<TCertificateAuthorityOcspServiceFactory, "invalidateCachedResponse">;
+ internalCertificateAuthorityDAL: Pick<TInternalCertificateAuthorityDALFactory, "update">;
};
export type TCertificateServiceFactory = ReturnType<typeof certificateServiceFactory>;
@@ -197,7 +197,7 @@ export const certificateServiceFactory = ({
keyStore,
usageMeteringService,
hsmConnectorService,
- certificateAuthorityOcspService
+ internalCertificateAuthorityDAL
}: TCertificateServiceFactoryDep) => {
const $canActOnCertViaApplication = async (
cert: { applicationId?: string | null; projectId: string },
@@ -522,7 +522,13 @@ export const certificateServiceFactory = ({
);
}
- return certificateDAL.deleteById(cert.id, tx);
+ const removed = await certificateDAL.deleteById(cert.id, tx);
+
+ if (cert.caId) {
+ await internalCertificateAuthorityDAL.update({ caId: cert.caId }, { $incr: { ocspGeneration: 1 } }, tx);
+ }
+
+ return removed;
});
} catch (err) {
const innerError = err instanceof DatabaseError ? (err.error as { code?: string; constraint?: string }) : null;
@@ -539,20 +545,6 @@ export const certificateServiceFactory = ({
throw err;
}
- if (cert.caId) {
- try {
- await certificateAuthorityOcspService.invalidateCachedResponse({
- caId: cert.caId,
- serialNumber: cert.serialNumber
- });
- } catch (error) {
- logger.error(
- error,
- `Failed to invalidate OCSP cache after deletion [caId=${cert.caId}] [serialNumber=${cert.serialNumber}]`
- );
- }
- }
-
await triggerSyncsForDeletedCertificate(
cert.id,
pkiSyncIdsHoldingCertificate,
@@ -735,16 +727,24 @@ export const certificateServiceFactory = ({
}
const revokedAt = new Date();
- await certificateDAL.update(
- {
- id: cert.id
- },
- {
- status: CertStatus.REVOKED,
- revokedAt,
- revocationReason: revocationReasonToCrlCode(revocationReason)
+ const revokedCertId = cert.id;
+ await certificateDAL.transaction(async (tx) => {
+ await certificateDAL.update(
+ {
+ id: revokedCertId
+ },
+ {
+ status: CertStatus.REVOKED,
+ revokedAt,
+ revocationReason: revocationReasonToCrlCode(revocationReason)
+ },
+ tx
+ );
+
+ if (!ca.externalCa?.id) {
+ await internalCertificateAuthorityDAL.update({ caId: ca.id }, { $incr: { ocspGeneration: 1 } }, tx);
}
- );
+ });
usageMeteringService.emitForProject(ca.projectId, ActiveCerts.key);
usageMeteringService.emitForProject(ca.projectId, WildcardCerts.key);
@@ -763,18 +763,6 @@ export const certificateServiceFactory = ({
// rebuild CRL (TODO: move to interval-based cron job)
// Only rebuild CRL for internal CAs - external CAs manage their own CRLs
if (!ca.externalCa?.id) {
- try {
- await certificateAuthorityOcspService.invalidateCachedResponse({
- caId: ca.id,
- serialNumber: cert.serialNumber
- });
- } catch (error) {
- logger.error(
- error,
- `Failed to invalidate OCSP cache after revocation [caId=${ca.id}] [serialNumber=${cert.serialNumber}]`
- );
- }
-
await rebuildCaCrl({
caId: ca.id,
certificateAuthorityDAL,
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaOcspSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaOcspSection.tsx
index 2416722411..93e8cdd781 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaOcspSection.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaOcspSection.tsx
@@ -8,14 +8,7 @@ import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import {
- Button as ButtonV2,
- FormControl,
- Modal,
- ModalClose,
- ModalContent,
- Switch
-} from "@app/components/v2";
-import {
+ Button,
Card,
CardAction,
CardContent,
@@ -26,7 +19,19 @@ import {
DetailGroup,
DetailLabel,
DetailValue,
- IconButton
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldContent,
+ FieldDescription,
+ FieldTitle,
+ IconButton,
+ Toggle
} from "@app/components/v3";
import {
ProjectPermissionCertificateAuthorityActions,
@@ -96,10 +101,7 @@ export const CaOcspSection = ({ caId }: Props) => {
});
handlePopUpToggle("editOcsp", false);
} catch {
- createNotification({
- text: "Failed to update OCSP",
- type: "error"
- });
+ // MutationCache.onError already surfaces the server message, so the dialog only stays open
}
};
@@ -116,6 +118,7 @@ export const CaOcspSection = ({ caId }: Props) => {
>
{(isAllowed) => (
<IconButton
+ aria-label="Edit OCSP"
variant="outline"
size="xs"
isDisabled={!isAllowed}
@@ -147,50 +150,54 @@ export const CaOcspSection = ({ caId }: Props) => {
</CardContent>
</Card>
- <Modal
- isOpen={popUp.editOcsp.isOpen}
+ <Dialog
+ open={popUp.editOcsp.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("editOcsp", isOpen);
if (!isOpen) reset();
}}
>
- <ModalContent title="Edit OCSP">
- <form onSubmit={handleSubmit(onEditSubmit)}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Edit OCSP</DialogTitle>
+ <DialogDescription>
+ Only certificates issued after OCSP is enabled carry the responder URL.
+ </DialogDescription>
+ </DialogHeader>
+ <form onSubmit={handleSubmit(onEditSubmit)} className="flex flex-col gap-4">
<Controller
control={control}
name="isOcspEnabled"
render={({ field: { value, onChange } }) => (
- <FormControl helperText="Only certificates issued after OCSP is enabled carry the responder URL.">
- <Switch
+ <Field orientation="horizontal">
+ <FieldContent>
+ <FieldTitle>Enable OCSP</FieldTitle>
+ <FieldDescription>
+ Answer revocation status checks for certificates issued by this CA.
+ </FieldDescription>
+ </FieldContent>
+ <Toggle
id="isOcspEnabled"
- className="bg-muted/80 shadow-inner data-[state=checked]:bg-success/80"
- thumbClassName="bg-surface-raised"
- isChecked={value}
+ variant="success"
+ checked={value}
onCheckedChange={onChange}
- >
- Enable OCSP
- </Switch>
- </FormControl>
+ />
+ </Field>
)}
/>
- <div className="flex w-full justify-between gap-4 pt-4">
- <ModalClose asChild>
- <ButtonV2 colorSchema="secondary" variant="plain">
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button type="button" variant="ghost">
Cancel
- </ButtonV2>
- </ModalClose>
- <ButtonV2
- type="submit"
- colorSchema="secondary"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
+ </Button>
+ </DialogClose>
+ <Button type="submit" isPending={isSubmitting} isDisabled={isSubmitting}>
Save
- </ButtonV2>
- </div>
+ </Button>
+ </DialogFooter>
</form>
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
<UpgradePlanModal
paywallKey="cert-manager.ca-ocsp"