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
Address PR comments
Carlos Monastyrski59638f2cf955
diff --git a/backend/src/db/schemas/pki-signer-certificate-issuance-jobs.ts b/backend/src/db/schemas/pki-signer-certificate-issuance-jobs.tsindex 8df42ad5e4..5658ac86e3 100644--- a/backend/src/db/schemas/pki-signer-certificate-issuance-jobs.ts+++ b/backend/src/db/schemas/pki-signer-certificate-issuance-jobs.ts@@ -32,8 +32,8 @@ export const PkiSignerCertificateIssuanceJobsSchema = z.object({keySource: z.string().default("infisical"),hsmConnectorId: z.string().uuid().nullable().optional(),hsmKeyLabel: z.string().nullable().optional(),- hsmKeyId: z.string().nullable().optional(),- hsmPublicKeySpki: zodBuffer.nullable().optional()+ hsmPublicKeySpki: zodBuffer.nullable().optional(),+ hsmKeyId: z.string().nullable().optional()});export type TPkiSignerCertificateIssuanceJobs = z.infer<typeof PkiSignerCertificateIssuanceJobsSchema>;diff --git a/backend/src/services/signer/signer-dal.ts b/backend/src/services/signer/signer-dal.tsindex 5aed15c5ec..14b00a523d 100644--- a/backend/src/services/signer/signer-dal.ts+++ b/backend/src/services/signer/signer-dal.ts@@ -177,5 +177,33 @@ export const signerDALFactory = (db: TDbClient) => {}};- return { ...orm, findByIdWithCertificate, findByStatusWithCertificate, findByProjectId, countByProjectId };+ const findOneByCurrentHsmKey = async (+ hsmConnectorId: string,+ hsmPublicKeySpki: Buffer,+ excludeSignerId: string | undefined,+ tx?: Knex+ ): Promise<TPkiSigners | undefined> => {+ try {+ let query = (tx || db.replicaNode())(TableName.PkiSigners)+ .join(TableName.Certificate, `${TableName.PkiSigners}.certificateId`, `${TableName.Certificate}.id`)+ .where(`${TableName.Certificate}.hsmConnectorId`, hsmConnectorId)+ .where(`${TableName.Certificate}.hsmPublicKeySpki`, hsmPublicKeySpki)+ .select(selectAllTableCols(TableName.PkiSigners));+ if (excludeSignerId) {+ query = query.whereNot(`${TableName.PkiSigners}.id`, excludeSignerId);+ }+ return (await query.first()) as TPkiSigners | undefined;+ } catch (error) {+ throw new DatabaseError({ error, name: "FindSignerByCurrentHsmKey" });+ }+ };++ return {+ ...orm,+ findByIdWithCertificate,+ findByStatusWithCertificate,+ findByProjectId,+ countByProjectId,+ findOneByCurrentHsmKey+ };};diff --git a/backend/src/services/signer/signer-service.ts b/backend/src/services/signer/signer-service.tsindex 5d830e67ea..823c7f780d 100644--- a/backend/src/services/signer/signer-service.ts+++ b/backend/src/services/signer/signer-service.ts@@ -521,6 +521,17 @@ export const signerServiceFactory = ({message: `The certificate in DigiCert order ${imported.orderId} is already used by signer '${signerUsingCertificate.name}'.`});}+ const signerUsingKey = await signerDAL.findOneByCurrentHsmKey(+ imported.hsm.hsmConnectorId,+ imported.hsm.hsmPublicKeySpki,+ signerId,+ tx+ );+ if (signerUsingKey) {+ throw new ConflictError({+ message: `The private key of the certificate in DigiCert order ${imported.orderId} is already used by another signer. Each signer needs its own key.`+ });+ }await certificateDAL.updateById(imported.certificateId, imported.hsm, tx);};diff --git a/frontend/src/pages/cert-manager/components/DigiCertExistingOrderField.tsx b/frontend/src/pages/cert-manager/components/DigiCertExistingOrderField.tsxindex 02270c2e29..27c2a424d4 100644--- a/frontend/src/pages/cert-manager/components/DigiCertExistingOrderField.tsx+++ b/frontend/src/pages/cert-manager/components/DigiCertExistingOrderField.tsx@@ -38,18 +38,11 @@ export const DigiCertExistingOrderField = ({ form, digicert }: DigiCertExistingOdigicert.productNameId);- const now = Date.now();- const orderOptions = codeSigningOrders- .filter(- (o) =>- o.status.toLowerCase() === "issued" &&- (!o.validTill || new Date(o.validTill).getTime() > now)- )- .map((o) => ({- value: String(o.orderId),- label: `${o.commonName || o.organizationName || "Code signing certificate"} (#${o.orderId})`,- commonName: o.commonName- }));+ const orderOptions = codeSigningOrders.map((o) => ({+ value: String(o.orderId),+ label: `${o.commonName || o.organizationName || "Code signing certificate"} (#${o.orderId})`,+ commonName: o.commonName+ }));type OrderOption = (typeof orderOptions)[number];const externalOrderId = form.watch("externalOrderId") as string | null;diff --git a/frontend/src/pages/cert-manager/components/SignerKeyStep.tsx b/frontend/src/pages/cert-manager/components/SignerKeyStep.tsxindex f417a13b4b..cccc92140e 100644--- a/frontend/src/pages/cert-manager/components/SignerKeyStep.tsx+++ b/frontend/src/pages/cert-manager/components/SignerKeyStep.tsx@@ -278,6 +278,12 @@ export const SignerKeyStep = ({<FieldDescription>Sign with the certificate already issued in this order and its key on the HSM.</FieldDescription>+ {field.value !== ExternalOrderMode.UseExisting && (+ <FieldDescription className="text-warning">+ Reissuing replaces the certificate in this order. DigiCert revokes the previous+ one within 72 hours, after which it can no longer be used to sign.+ </FieldDescription>+ )}</FieldContent><Toggleid="use-existing-key"