Skip to content

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

Address PR comments

Carlos Monastyrskia8535c83e357
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index 0c7b8750c6..b93550d327 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -958,6 +958,13 @@ pointing at something. Things that rely on that:
saw when the row was hard deleted. The one background job that still reads deleted rows is the DigiCert
revocation sync: it records an upstream revocation on a deleted certificate (without alerts) so the quota
stops counting it.
+- **The foreign key no longer stops a write that references a deleted certificate.** A hard delete made any
+ later insert pointing at the row fail; the kept row accepts it. So every write that attaches something to a
+ certificate (sync link, collection item, signer, metadata, Application) locks the row `FOR SHARE` or
+ `FOR UPDATE` inside its own transaction and rechecks `deletedAt` on the locked copy; a check before the
+ transaction races the delete. `certificateSyncDAL.addCertificates` and `claimExternalIdentifier` do this
+ themselves and skip deleted ids, so every sync provider is covered. A new writer belongs in that DAL or
+ follows the same pattern.
- **The licence quota still counts a deleted certificate Infisical issued until it expires or is revoked**,
because deleting neither revokes it nor requires it to be expired, so excluding it would let an org free
its cap while the certificate stays trusted. Deleted imported and discovered certificates stop counting, as
@@ -982,7 +989,7 @@ pointing at something. Things that rely on that:
so the inventory can still show where a deleted certificate is deployed.
- **Discovery matches deleted rows by fingerprint, and certificates issued before 2026-01-27 have none.** The
delete computes and stores a missing fingerprint before it removes the body, so discovery can still find the
- deleted row.
+ deleted row. If the body can't be read, the delete fails and nothing is removed.
- **A deleted certificate can keep `keySource = hsm` after its HSM connector is deleted.** The key source CHECK
allows a null `hsmConnectorId` on deleted rows, so deleting a connector only detaches them and the record
still says the key lived in an HSM.
diff --git a/backend/src/db/migrations/20261020143827_add-soft-delete-to-certificates.ts b/backend/src/db/migrations/20261020143827_add-soft-delete-to-certificates.ts
index 6b2d845d1e..abd2037f52 100644
--- a/backend/src/db/migrations/20261020143827_add-soft-delete-to-certificates.ts
+++ b/backend/src/db/migrations/20261020143827_add-soft-delete-to-certificates.ts
@@ -112,10 +112,7 @@ export async function down(knex: Knex): Promise<void> {
});
if (await knex.schema.hasColumn(TableName.Certificate, "deletedAt")) {
- await knex(TableName.Certificate)
- .where("keySource", "hsm")
- .whereNull("hsmConnectorId")
- .update({ keySource: "infisical", hsmKeyLabel: null, hsmKeyId: null, hsmPublicKeySpki: null });
+ await knex(TableName.Certificate).whereNotNull("deletedAt").delete();
await replaceKeySourceCheck(knex, LIVE_HSM_KEY_SOURCE_CHECK);
}
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 385778c138..36e927c646 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -3296,7 +3296,7 @@ interface DeleteCert {
notAfter: string;
source: CertificateSource;
statusAtDeletion: CertStatus;
- deletionAllowedReason?: CertificateDeletionEligibility;
+ deletionAllowedReason: CertificateDeletionEligibility;
applicationId?: string | null;
applicationName?: string | null;
};
diff --git a/backend/src/services/certificate-sync/certificate-sync-dal.ts b/backend/src/services/certificate-sync/certificate-sync-dal.ts
index 1ebdf26b5a..5abdac14fa 100644
--- a/backend/src/services/certificate-sync/certificate-sync-dal.ts
+++ b/backend/src/services/certificate-sync/certificate-sync-dal.ts
@@ -14,6 +14,23 @@ type CertificateSyncFindFilter = Parameters<typeof buildFindFilter<TCertificateS
export const certificateSyncDALFactory = (db: TDbClient) => {
const certificateSyncOrm = ormify(db, TableName.CertificateSync);
+ const $withLiveCertificateIds = async <T>(
+ certificateIds: string[],
+ tx: Knex | undefined,
+ write: (liveIds: Set<string>, trx: Knex) => Promise<T>
+ ): Promise<T> => {
+ const run = async (trx: Knex) => {
+ const rows = (await trx(TableName.Certificate)
+ .whereIn("id", certificateIds)
+ .whereNull("deletedAt")
+ .orderBy("id")
+ .forShare()
+ .select("id")) as Array<{ id: string }>;
+ return write(new Set(rows.map(({ id }) => id)), trx);
+ };
+ return tx ? run(tx) : db.transaction(run);
+ };
+
const findByPkiSyncId = async (pkiSyncId: string, tx?: Knex) => {
try {
const docs = await (tx || db.replicaNode())(TableName.CertificateSync)
@@ -97,16 +114,19 @@ export const certificateSyncDALFactory = (db: TDbClient) => {
tx?: Knex
): Promise<void> => {
try {
- await (tx || db)(TableName.CertificateSync)
- .insert({ pkiSyncId, certificateId, syncStatus: CertificateSyncStatus.Pending, externalIdentifier })
- .onConflict(["pkiSyncId", "certificateId"])
- .ignore();
- await (tx || db)(TableName.CertificateSync)
- .where({ pkiSyncId, certificateId })
- .where((qb) => {
- void qb.whereNull("externalIdentifier").orWhereNot("externalIdentifier", externalIdentifier);
- })
- .update({ externalIdentifier });
+ await $withLiveCertificateIds([certificateId], tx, async (liveIds, trx) => {
+ if (!liveIds.has(certificateId)) return;
+ await trx(TableName.CertificateSync)
+ .insert({ pkiSyncId, certificateId, syncStatus: CertificateSyncStatus.Pending, externalIdentifier })
+ .onConflict(["pkiSyncId", "certificateId"])
+ .ignore();
+ await trx(TableName.CertificateSync)
+ .where({ pkiSyncId, certificateId })
+ .where((qb) => {
+ void qb.whereNull("externalIdentifier").orWhereNot("externalIdentifier", externalIdentifier);
+ })
+ .update({ externalIdentifier });
+ });
} catch (error) {
throw new DatabaseError({ error, name: "ClaimExternalIdentifier" });
}
@@ -118,16 +138,23 @@ export const certificateSyncDALFactory = (db: TDbClient) => {
tx?: Knex
): Promise<TCertificateSyncs[]> => {
try {
- const insertData = certificateData.map(({ certificateId, externalIdentifier }) => ({
- pkiSyncId,
- certificateId,
- syncStatus: CertificateSyncStatus.Pending,
- externalIdentifier
- }));
-
- const docs = await (tx || db)(TableName.CertificateSync).insert(insertData).returning("*");
-
- return docs;
+ return await $withLiveCertificateIds(
+ certificateData.map(({ certificateId }) => certificateId),
+ tx,
+ async (liveIds, trx) => {
+ const insertData = certificateData
+ .filter(({ certificateId }) => liveIds.has(certificateId))
+ .map(({ certificateId, externalIdentifier }) => ({
+ pkiSyncId,
+ certificateId,
+ syncStatus: CertificateSyncStatus.Pending,
+ externalIdentifier
+ }));
+ if (insertData.length === 0) return [];
+
+ return trx(TableName.CertificateSync).insert(insertData).returning("*");
+ }
+ );
} catch (error) {
throw new DatabaseError({ error, name: "AddCertificates" });
}
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 6f0e8a2951..52243b2478 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.test.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.test.ts
@@ -92,6 +92,7 @@ describe("CertificateV3Service", () => {
| "findOne"
| "findById"
| "findByIdForUpdate"
+ | "findByIdForShare"
| "updateById"
| "transaction"
| "create"
@@ -104,6 +105,7 @@ describe("CertificateV3Service", () => {
findOne: vi.fn(),
findById: vi.fn(),
findByIdForUpdate: vi.fn(),
+ findByIdForShare: vi.fn(),
findCertificatesMatchingSyncFilters: vi.fn().mockResolvedValue([]),
findActiveCertificatesByIds: vi.fn().mockResolvedValue([]),
updateById: vi.fn(),
diff --git a/backend/src/services/certificate-v3/certificate-v3-service.ts b/backend/src/services/certificate-v3/certificate-v3-service.ts
index c209e1e42d..93979e7b84 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.ts
@@ -142,6 +142,7 @@ type TCertificateV3ServiceFactoryDep = {
| "findOne"
| "findById"
| "findByIdForUpdate"
+ | "findByIdForShare"
| "updateById"
| "transaction"
| "create"
@@ -2340,6 +2341,11 @@ export const certificateV3ServiceFactory = ({
if (metadata) {
await certificateDAL.transaction(async (tx) => {
+ const lockedCertificate = await certificateDAL.findByIdForShare(certificateId, tx);
+ if (!lockedCertificate) {
+ throw new NotFoundError({ message: "Certificate not found" });
+ }
+ assertCertificateNotDeleted(lockedCertificate);
await resourceMetadataDAL.delete({ certificateId }, tx);
await insertMetadataForCertificate(resourceMetadataDAL, {
metadata,
diff --git a/backend/src/services/certificate/certificate-dal.ts b/backend/src/services/certificate/certificate-dal.ts
index b7e01f9113..6169b5c4a3 100644
--- a/backend/src/services/certificate/certificate-dal.ts
+++ b/backend/src/services/certificate/certificate-dal.ts
@@ -1529,21 +1529,6 @@ export const certificateDALFactory = (db: TDbClient) => {
}
};
- const findLiveIdsForShare = async (ids: string[], tx: Knex): Promise<string[]> => {
- if (ids.length === 0) return [];
- try {
- const rows = (await tx(TableName.Certificate)
- .whereIn("id", ids)
- .whereNull("deletedAt")
- .orderBy("id")
- .forShare()
- .select("id")) as Array<{ id: string }>;
- return rows.map(({ id }) => id);
- } catch (error) {
- throw new DatabaseError({ error, name: "Find live certificate ids for share" });
- }
- };
-
const primaryNode = () => db.primaryNode();
return {
@@ -1551,7 +1536,6 @@ export const certificateDALFactory = (db: TDbClient) => {
...certificateOrm,
findByIdForUpdate,
findByIdForShare,
- findLiveIdsForShare,
restoreDeleted,
create,
countCertificatesInProject,
diff --git a/backend/src/services/certificate/certificate-fns.test.ts b/backend/src/services/certificate/certificate-fns.test.ts
index fa459292a7..2c3d22cfce 100644
--- a/backend/src/services/certificate/certificate-fns.test.ts
+++ b/backend/src/services/certificate/certificate-fns.test.ts
@@ -309,23 +309,20 @@ describe("resolveCertificateDeletionEligibility", () => {
const future = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000);
const past = new Date(Date.now() - 24 * 60 * 60 * 1000);
- it("allows an expired certificate", () => {
- expect(resolveCertificateDeletionEligibility({ status: CertStatus.ACTIVE, notAfter: past })).toBe(
+ it("reports an expired certificate", () => {
+ expect(resolveCertificateDeletionEligibility({ status: CertStatus.REVOKED, notAfter: past })).toBe(
CertificateDeletionEligibility.Expired
);
});
- it("allows a discovered certificate that has not expired", () => {
+ it("reports discovered and imported certificates by source, revoked or not", () => {
expect(
resolveCertificateDeletionEligibility({
- status: CertStatus.ACTIVE,
+ status: CertStatus.REVOKED,
notAfter: future,
source: CertificateSource.Discovered
})
).toBe(CertificateDeletionEligibility.Discovered);
- });
-
- it("allows an imported certificate that has not expired", () => {
expect(
resolveCertificateDeletionEligibility({
status: CertStatus.ACTIVE,
@@ -335,45 +332,12 @@ describe("resolveCertificateDeletionEligibility", () => {
).toBe(CertificateDeletionEligibility.Imported);
});
- it("blocks an issued certificate that has not expired", () => {
- expect(
- resolveCertificateDeletionEligibility({
- status: CertStatus.ACTIVE,
- notAfter: future,
- source: CertificateSource.Issued
- })
- ).toBeNull();
- });
-
- it("blocks a certificate with no source, because issuance never records one", () => {
- expect(resolveCertificateDeletionEligibility({ status: CertStatus.ACTIVE, notAfter: future })).toBeNull();
- });
-
- it("blocks a revoked certificate until it expires, so its serial stays on the CRL", () => {
- expect(resolveCertificateDeletionEligibility({ status: CertStatus.REVOKED, notAfter: future })).toBeNull();
- });
-
- it("blocks a revoked certificate even when its source would exempt it", () => {
- expect(
- resolveCertificateDeletionEligibility({
- status: CertStatus.REVOKED,
- notAfter: future,
- source: CertificateSource.Imported
- })
- ).toBeNull();
-
- expect(
- resolveCertificateDeletionEligibility({
- status: CertStatus.REVOKED,
- notAfter: future,
- source: CertificateSource.Discovered
- })
- ).toBeNull();
- });
-
- it("allows a revoked certificate once it has expired", () => {
- expect(resolveCertificateDeletionEligibility({ status: CertStatus.REVOKED, notAfter: past })).toBe(
- CertificateDeletionEligibility.Expired
+ it("always returns a reason, so the audit event keeps the field", () => {
+ expect(resolveCertificateDeletionEligibility({ status: CertStatus.ACTIVE, notAfter: future })).toBe(
+ CertificateDeletionEligibility.Issued
+ );
+ expect(resolveCertificateDeletionEligibility({ status: CertStatus.REVOKED, notAfter: future })).toBe(
+ CertificateDeletionEligibility.Issued
);
});
});
diff --git a/backend/src/services/certificate/certificate-fns.ts b/backend/src/services/certificate/certificate-fns.ts
index b2ca417773..e92f49293d 100644
--- a/backend/src/services/certificate/certificate-fns.ts
+++ b/backend/src/services/certificate/certificate-fns.ts
@@ -546,16 +546,12 @@ export const resolveCertificateDeletionEligibility = (certificate: {
status: string;
notAfter: Date;
source?: string | null;
-}): CertificateDeletionEligibility | null => {
- const hasExpired = new Date(certificate.notAfter).getTime() <= Date.now();
-
- if (!hasExpired && certificate.status === CertStatus.REVOKED) return null;
-
+}): CertificateDeletionEligibility => {
if (certificate.source === CertificateSource.Discovered) return CertificateDeletionEligibility.Discovered;
if (certificate.source === CertificateSource.Imported) return CertificateDeletionEligibility.Imported;
- if (hasExpired) return CertificateDeletionEligibility.Expired;
+ if (new Date(certificate.notAfter).getTime() <= Date.now()) return CertificateDeletionEligibility.Expired;
- return null;
+ return CertificateDeletionEligibility.Issued;
};
type TDeletableCertificate = {
diff --git a/backend/src/services/certificate/certificate-service.ts b/backend/src/services/certificate/certificate-service.ts
index 4f32e9f5f1..1d7283f3ec 100644
--- a/backend/src/services/certificate/certificate-service.ts
+++ b/backend/src/services/certificate/certificate-service.ts
@@ -20,7 +20,7 @@ import {
import { CertificateSource } from "@app/ee/services/pki-discovery/pki-discovery-types";
import { TKeyStoreFactory } from "@app/keystore/keystore";
import { crypto } from "@app/lib/crypto/cryptography";
-import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
+import { BadRequestError, ForbiddenRequestError, InternalServerError, NotFoundError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { Pkcs12PasswordSchema } from "@app/lib/validator/password-policy";
import { ActorType } from "@app/services/auth/auth-type";
@@ -607,8 +607,11 @@ export const certificateServiceFactory = ({
: await $parseStoredCertificateBody(cert)
.then((parsed) => parsed?.fingerprints)
.catch((error: unknown) => {
- logger.warn(error, `Could not read fingerprints before deleting certificate [certificateId=${cert.id}]`);
- return undefined;
+ logger.error(error, `Could not read fingerprints before deleting certificate [certificateId=${cert.id}]`);
+ throw new InternalServerError({
+ error,
+ message: `Certificate '${getCertificateDisplayName(cert)}' could not be read to record its fingerprint, which is needed to recognize it if it is imported or discovered again. It was not deleted. Try again in a few minutes.`
+ });
});
const { deletedCert, pkiSyncIdsHoldingCertificate } = await certificateDAL.transaction(async (tx) => {
@@ -666,7 +669,7 @@ export const certificateServiceFactory = ({
return {
deletedCert,
statusAtDeletion: resolveCertificateStatus(deletedCert),
- deletionAllowedReason: resolveCertificateDeletionEligibility(deletedCert) ?? undefined,
+ deletionAllowedReason: resolveCertificateDeletionEligibility(deletedCert),
applicationName: await $resolveApplicationName(deletedCert.applicationId)
};
};
@@ -1867,9 +1870,19 @@ export const certificateServiceFactory = ({
});
}
- assertCertificateNotDeleted(cert);
-
- const [updatedCert] = await certificateDAL.update({ id: cert.id }, { applicationId });
+ const updatedCert = await certificateDAL.transaction(async (tx) => {
+ const lockedCert = await certificateDAL.findByIdForUpdate(cert.id, tx);
+ if (!lockedCert) {
+ throw new NotFoundError({ message: `Certificate with id '${certificateId}' not found.` });
+ }
+ assertCertificateNotDeleted(lockedCert);
+ if (lockedCert.applicationId) {
+ throw new BadRequestError({
+ message: "This certificate is already assigned to an Application and cannot be moved."
+ });
+ }
+ return certificateDAL.updateById(cert.id, { applicationId }, tx);
+ });
await queueCertificateFilterReconcile(cert.id, applicationId, pkiSyncQueue);
diff --git a/backend/src/services/certificate/certificate-types.ts b/backend/src/services/certificate/certificate-types.ts
index c687396e45..fe34754fcf 100644
--- a/backend/src/services/certificate/certificate-types.ts
+++ b/backend/src/services/certificate/certificate-types.ts
@@ -24,7 +24,8 @@ export enum CertStatus {
export enum CertificateDeletionEligibility {
Expired = "expired",
Discovered = "discovered",
- Imported = "imported"
+ Imported = "imported",
+ Issued = "issued"
}
export enum CertificateRestoreSource {
diff --git a/backend/src/services/pki-collection/pki-collection-service.ts b/backend/src/services/pki-collection/pki-collection-service.ts
index 3975ad5d1e..c590ac97ee 100644
--- a/backend/src/services/pki-collection/pki-collection-service.ts
+++ b/backend/src/services/pki-collection/pki-collection-service.ts
@@ -29,7 +29,7 @@ type TPkiCollectionServiceFactoryDep = {
"findOne" | "create" | "deleteById" | "findPkiCollectionItems" | "countItemsInPkiCollection"
>;
certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory, "find" | "findOne">;
- certificateDAL: Pick<TCertificateDALFactory, "find">;
+ certificateDAL: Pick<TCertificateDALFactory, "find" | "findByIdForShare" | "transaction">;
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
};
@@ -265,9 +265,12 @@ export const pkiCollectionServiceFactory = ({
if (!certificate) throw new NotFoundError({ message: `Certificate with ID '${itemId}' not found` });
assertCertificateNotDeleted(certificate, "be added to a collection");
- pkiCollectionItem = await pkiCollectionItemDAL.create({
- pkiCollectionId: collectionId,
- certId: itemId
+ pkiCollectionItem = await certificateDAL.transaction(async (tx) => {
+ const lockedCertificate = await certificateDAL.findByIdForShare(itemId, tx);
+ if (!lockedCertificate) throw new NotFoundError({ message: `Certificate with ID '${itemId}' not found` });
+ assertCertificateNotDeleted(lockedCertificate, "be added to a collection");
+
+ return pkiCollectionItemDAL.create({ pkiCollectionId: collectionId, certId: itemId }, tx);
});
break;
}
diff --git a/backend/src/services/pki-sync/pki-sync-filter-reconcile-fns.ts b/backend/src/services/pki-sync/pki-sync-filter-reconcile-fns.ts
index 0cd74785b4..c75f4a898d 100644
--- a/backend/src/services/pki-sync/pki-sync-filter-reconcile-fns.ts
+++ b/backend/src/services/pki-sync/pki-sync-filter-reconcile-fns.ts
@@ -33,7 +33,7 @@ export type TPkiSyncReconcileTarget = {
};
type TPkiSyncFilterReconcileDeps = {
- certificateDAL: Pick<TCertificateDALFactory, "findCertificatesMatchingSyncFilters" | "find" | "findLiveIdsForShare">;
+ certificateDAL: Pick<TCertificateDALFactory, "findCertificatesMatchingSyncFilters" | "find">;
certificateSyncDAL: Pick<
TCertificateSyncDALFactory,
| "findCertificateIdsByPkiSyncId"
@@ -193,7 +193,7 @@ export const applyPkiSyncCertificateDiff = async (
writeFilters?: (tx: Knex) => Promise<void>,
removalOptions?: TPkiSyncRemovalOptions
): Promise<{ linked: TPkiSyncCertificateRef[]; unlinked: TPkiSyncCertificateRef[] }> => {
- const { certificateDAL, certificateSyncDAL, pkiSyncQueue, auditLogService, pkiApplicationDAL } = deps;
+ const { certificateSyncDAL, pkiSyncQueue, auditLogService, pkiApplicationDAL } = deps;
const { toUnlink } = diff;
let { toLink } = diff;
@@ -211,20 +211,14 @@ export const applyPkiSyncCertificateDiff = async (
await certificateSyncDAL.transaction(async (tx) => {
if (writeFilters) await writeFilters(tx);
- const liveIds = new Set(
- await certificateDAL.findLiveIdsForShare(
- toLink.map((certificate) => certificate.id),
- tx
- )
- );
- toLink = toLink.filter((certificate) => liveIds.has(certificate.id));
-
if (toLink.length > 0) {
- await certificateSyncDAL.addCertificates(
+ const linked = await certificateSyncDAL.addCertificates(
pkiSync.id,
toLink.map((certificate) => ({ certificateId: certificate.id })),
tx
);
+ const linkedIds = new Set(linked.map(({ certificateId }) => certificateId));
+ toLink = toLink.filter((certificate) => linkedIds.has(certificate.id));
}
if (idsOnlyLinked.length > 0) {
diff --git a/backend/src/services/pki-sync/pki-sync-service.ts b/backend/src/services/pki-sync/pki-sync-service.ts
index 46d1065cb6..d963de676c 100644
--- a/backend/src/services/pki-sync/pki-sync-service.ts
+++ b/backend/src/services/pki-sync/pki-sync-service.ts
@@ -126,7 +126,6 @@ type TPkiSyncServiceFactoryDep = {
TCertificateDALFactory,
| "find"
| "findCertificatesMatchingSyncFilters"
- | "findLiveIdsForShare"
| "countCertificatesMatchingSyncFilters"
| "findReadableCertificateIds"
| "findLatestCertificatesByOrderIds"
diff --git a/backend/src/services/pki-sync/pki-sync-utils.ts b/backend/src/services/pki-sync/pki-sync-utils.ts
index b54031b0df..a842a1998e 100644
--- a/backend/src/services/pki-sync/pki-sync-utils.ts
+++ b/backend/src/services/pki-sync/pki-sync-utils.ts
@@ -208,11 +208,7 @@ export const addRenewedCertificateToSyncs = async (
type TReconcileCertificateAgainstSyncsDeps = {
certificateDAL: Pick<
TCertificateDALFactory,
- | "findActiveCertificatesByIds"
- | "findCertificatesMatchingSyncFilters"
- | "find"
- | "primaryNode"
- | "findLiveIdsForShare"
+ "findActiveCertificatesByIds" | "findCertificatesMatchingSyncFilters" | "find" | "primaryNode"
>;
certificateSyncDAL: Pick<
TCertificateSyncDALFactory,
diff --git a/backend/src/services/signer/signer-service.ts b/backend/src/services/signer/signer-service.ts
index aa98dbf0cc..d98b81282a 100644
--- a/backend/src/services/signer/signer-service.ts
+++ b/backend/src/services/signer/signer-service.ts
@@ -576,7 +576,11 @@ export const signerServiceFactory = ({
const certificateId = preparedCertificate.insert
? await preparedCertificate.insert(tx)
: preparedCertificate.existingCertificateId;
- await certificateDAL.findByIdForUpdate(certificateId, tx);
+ const lockedCertificate = await certificateDAL.findByIdForUpdate(certificateId, tx);
+ if (!lockedCertificate) {
+ throw new NotFoundError({ message: `The certificate in DigiCert order ${imported.orderId} no longer exists.` });
+ }
+ assertCertificateNotDeleted(lockedCertificate, "be used by a signer");
const signerUsingCertificate = await signerDAL.findOne({ certificateId }, tx);
if (signerUsingCertificate && signerUsingCertificate.id !== signerId) {
throw new ConflictError({
diff --git a/frontend/src/hooks/api/auditLogs/types.tsx b/frontend/src/hooks/api/auditLogs/types.tsx
index b5c94268da..edf9176b8e 100644
--- a/frontend/src/hooks/api/auditLogs/types.tsx
+++ b/frontend/src/hooks/api/auditLogs/types.tsx
@@ -721,7 +721,7 @@ interface DeleteCert {
notAfter: string;
source: string;
statusAtDeletion?: CertStatus;
- deletionAllowedReason?: string;
+ deletionAllowedReason: string;
applicationId?: string | null;
applicationName?: string | null;
};
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
index 2995e43ed5..4075d582a7 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
@@ -181,6 +181,27 @@ const SortIcon = ({
return <Icon className="ml-1 inline-block size-3" />;
};
+const getFiltersForSystemViewId = (viewId: string | undefined): FilterRule[] => {
+ if (viewId === "system-pqc") {
+ return [
+ { id: "sv-pqc", field: "keyAlgorithm", operator: "in", value: [...PQC_KEY_ALGORITHMS] },
+ liveCertificateStatusFilter("sv-pqc-status")
+ ];
+ }
+ if (viewId === "system-non-pqc") {
+ return [
+ {
+ id: "sv-non-pqc",
+ field: "keyAlgorithm",
+ operator: "in",
+ value: [...NON_PQC_KEY_ALGORITHMS]
+ },
+ liveCertificateStatusFilter("sv-non-pqc-status")
+ ];
+ }
+ return [];
+};
+
export const CertificatesTable = ({
handlePopUpOpen,
externalFilter,
@@ -223,27 +244,6 @@ export const CertificatesTable = ({
)
);
- const getFiltersForSystemViewId = (viewId: string | undefined): FilterRule[] => {
- if (viewId === "system-pqc") {
- return [
- { id: "sv-pqc", field: "keyAlgorithm", operator: "in", value: [...PQC_KEY_ALGORITHMS] },
- liveCertificateStatusFilter("sv-pqc-status")
- ];
- }
- if (viewId === "system-non-pqc") {
- return [
- {
- id: "sv-non-pqc",
- field: "keyAlgorithm",
- operator: "in",
- value: [...NON_PQC_KEY_ALGORITHMS]
- },
- liveCertificateStatusFilter("sv-non-pqc-status")
- ];
- }
- return [];
- };
-
const [appliedFilters, setAppliedFilters] = useState<FilterRule[]>(() => {
if (dashboardFilters?.length) return dashboardFilters;
return getFiltersForSystemViewId(dashboardViewId);
@@ -543,24 +543,8 @@ export const CertificatesTable = ({
setAppliedFilters([
{ id: "sv-status", field: "status", operator: "in", value: [CertStatus.DELETED] }
]);
- } else if (viewId === "system-pqc") {
- setAppliedFilters([
- {
- id: "sv-pqc",
- field: "keyAlgorithm",
- operator: "in",
- value: [...PQC_KEY_ALGORITHMS]
- }
- ]);
- } else if (viewId === "system-non-pqc") {
- setAppliedFilters([
- {
- id: "sv-non-pqc",
- field: "keyAlgorithm",
- operator: "in",
- value: [...NON_PQC_KEY_ALGORITHMS]
- }
- ]);
+ } else if (viewId === "system-pqc" || viewId === "system-non-pqc") {
+ setAppliedFilters(getFiltersForSystemViewId(viewId));
} else {
const customFilters = filters as TInventoryViewFilters;
const rules: FilterRule[] = [];