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 Monastyrskie4ed68245fc5
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex d049c79903..97b771aafe 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -2663,7 +2663,8 @@ export const CertificateAuthorities = {"Where the CA's signing key is generated and stored. 'infisical' keeps the key in Infisical's KMS; 'hsm' generates and stores the key in the HSM reached through the specified HSM Connector.",hsmConnectorId:"The ID of the HSM Connector to generate and store the CA's signing key in. Required when keySource is 'hsm'.",- hsmKeyLabel: "The label of the CA signing key on the HSM. Set automatically for HSM-backed CAs.",+ hsmKeyLabel:+ "The label of the CA's signing key on the HSM. Not user-supplied: it is the HSM Connector's configured key name prefix followed by a unique, server-generated per-CA suffix (ca-<uuid>).",crlDistributionPointUrls:"Additional CRL Distribution Point URLs (HTTP/HTTPS) embedded in every certificate issued by this CA. Up to 4 URLs; the Infisical-managed CRL endpoint is included by default unless disabled.",disableManagedCrlDistributionPointUrl:diff --git a/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts b/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.tsindex 01e4abd709..0860fbff9f 100644--- a/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts+++ b/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts@@ -369,8 +369,18 @@ export const internalCertificateAuthorityServiceFactory = ({);}- // Kept outside the transaction below (network round-trip); an aborted tx orphans a harmless- // unreferenced HSM key rather than holding a DB connection open across the call.+ // A duplicate name only fails the (name, projectId) unique constraint after the key is+ // generated, and an HSM key cannot be auto-removed, so reject a taken name before keygen to+ // avoid leaving an orphaned key on the HSM.+ if (name) {+ const existingCa = await certificateAuthorityDAL.findOne({ projectId, name });+ if (existingCa) {+ throw new BadRequestError({+ message: `A certificate authority named "${name}" already exists in this project.`+ });+ }+ }+const generated = await hsmConnectorService.generateKeyPair({connectorId: dto.hsmConnectorId,projectId,diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsxindex daa9694d47..dc93fbf447 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx@@ -19,7 +19,9 @@ import {ProjectPermissionSub,useProject} from "@app/context";-import { CaStatus, CaType, useDeleteCa, useUpdateCa } from "@app/hooks/api";+import { CaStatus, CaType, useDeleteCa, useGetCa, useUpdateCa } from "@app/hooks/api";+import { TInternalCertificateAuthority } from "@app/hooks/api/ca/types";+import { CertKeySource } from "@app/hooks/api/signers";import { usePopUp } from "@app/hooks/usePopUp";import { PkiDocsUrls } from "../../pki-docs-urls";@@ -41,6 +43,18 @@ export const CaSection = () => {"caStatus" // enable / disable] as const);+ const deleteCaId = (popUp?.deleteCa?.data as { caId?: string })?.caId;+ const { data: caPendingDeleteData } = useGetCa({+ caId: deleteCaId ?? "",+ type: CaType.INTERNAL,+ options: { enabled: popUp.deleteCa.isOpen && Boolean(deleteCaId) }+ });+ const caPendingDelete = caPendingDeleteData as TInternalCertificateAuthority | undefined;+ const pendingDeleteHsmKeyLabel =+ caPendingDelete?.configuration?.keySource === CertKeySource.Hsm+ ? caPendingDelete?.configuration?.hsmKeyLabel+ : undefined;+const onRemoveCaSubmit = async (id: string) => {if (!currentProject?.slug) return;@@ -107,7 +121,11 @@ export const CaSection = () => {title={`Are you sure you want to remove the CA ${(popUp?.deleteCa?.data as { dn: string })?.dn || ""}?`}- subTitle="This action will delete other CAs and certificates below it in your CA hierarchy."+ subTitle={`This action will delete other CAs and certificates below it in your CA hierarchy.${+ pendingDeleteHsmKeyLabel+ ? ` This CA's key on the HSM (label: ${pendingDeleteHsmKeyLabel}) is not removed automatically and will remain as an orphaned key.`+ : ""+ }`}onChange={(isOpen) => handlePopUpToggle("deleteCa", isOpen)}deleteKey="confirm"onDeleteApproved={() => onRemoveCaSubmit((popUp?.deleteCa?.data as { caId: string })?.caId)}