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
fix: add blocks for ca incompatibility
Sheen Capadnganc9763c83deec
diff --git a/backend/src/server/routes/v1/certificate-profiles-router.ts b/backend/src/server/routes/v1/certificate-profiles-router.tsindex 9a5ea19ee2..f35672978c 100644--- a/backend/src/server/routes/v1/certificate-profiles-router.ts+++ b/backend/src/server/routes/v1/certificate-profiles-router.ts@@ -328,7 +328,8 @@ export const registerCertificateProfilesRouter = async (status: z.string(),name: z.string(),isExternal: z.boolean().optional(),- externalType: z.string().nullable().optional()+ externalType: z.string().nullable().optional(),+ keyAlgorithm: z.string().nullable().optional()}).optional(),metrics: z@@ -437,7 +438,8 @@ export const registerCertificateProfilesRouter = async (status: z.string(),name: z.string(),isExternal: z.boolean().optional(),- externalType: z.string().nullable().optional()+ externalType: z.string().nullable().optional(),+ keyAlgorithm: z.string().nullable().optional()}).optional(),certificatePolicy: zdiff --git a/backend/src/services/certificate-common/certificate-issuance-utils.ts b/backend/src/services/certificate-common/certificate-issuance-utils.tsindex 667d33ef50..5cb3a26bdd 100644--- a/backend/src/services/certificate-common/certificate-issuance-utils.ts+++ b/backend/src/services/certificate-common/certificate-issuance-utils.ts@@ -172,6 +172,31 @@ export const validateCaSupport = (ca: TCertificateAuthorityWithAssociatedCa, opereturn caType;};+/**+ * A CA signs with its own key, so it can only produce signatures of that key's family. PQC keys are+ * their own signature algorithm and require an exact match.+ */+export const isSignatureAlgorithmCompatibleWithCaKey = (+ signatureAlgorithm: string,+ caKeyAlgorithm: string+): boolean => {+ if (signatureAlgorithm.startsWith("ML-DSA") || signatureAlgorithm.startsWith("SLH-DSA")) {+ return signatureAlgorithm === caKeyAlgorithm;+ }++ const parts = signatureAlgorithm.split("-");++ if (caKeyAlgorithm.startsWith("RSA")) {+ return parts.includes(CertKeyType.RSA);+ }++ if (caKeyAlgorithm.startsWith("EC")) {+ return parts.includes(CertKeyType.ECDSA);+ }++ return false;+};+/*** Validates that the CA's key algorithm is compatible with the template's signature algorithms*/@@ -193,24 +218,9 @@ export const validateAlgorithmCompatibility = (}const compatibleAlgorithms =- template.algorithms?.signature?.filter((sigAlg: string) => {- // PQC: key algorithm = signature algorithm, so require exact match- if (sigAlg.startsWith("ML-DSA") || sigAlg.startsWith("SLH-DSA")) {- return sigAlg === caKeyAlgorithm;- }-- const parts = sigAlg.split("-");-- if (caKeyAlgorithm.startsWith("RSA")) {- return parts.includes(CertKeyType.RSA);- }-- if (caKeyAlgorithm.startsWith("EC")) {- return parts.includes(CertKeyType.ECDSA);- }-- return false;- }) || [];+ template.algorithms?.signature?.filter((sigAlg: string) =>+ isSignatureAlgorithmCompatibleWithCaKey(sigAlg, caKeyAlgorithm)+ ) || [];if (compatibleAlgorithms.length === 0) {throw new BadRequestError({diff --git a/backend/src/services/certificate-profile/certificate-profile-dal.ts b/backend/src/services/certificate-profile/certificate-profile-dal.tsindex 2860c5d6d7..4517843bf7 100644--- a/backend/src/services/certificate-profile/certificate-profile-dal.ts+++ b/backend/src/services/certificate-profile/certificate-profile-dal.ts@@ -146,6 +146,11 @@ export const certificateProfileDALFactory = (db: TDbClient) => {`${TableName.CertificateAuthority}.id`,`${TableName.ExternalCertificateAuthority}.caId`)+ .leftJoin(+ TableName.InternalCertificateAuthority,+ `${TableName.CertificateAuthority}.id`,+ `${TableName.InternalCertificateAuthority}.caId`+ ).leftJoin(TableName.PkiCertificatePolicy,`${TableName.PkiCertificateProfile}.certificatePolicyId`,@@ -181,6 +186,7 @@ export const certificateProfileDALFactory = (db: TDbClient) => {db.ref("name").withSchema(TableName.CertificateAuthority).as("caName"),db.ref("id").withSchema(TableName.ExternalCertificateAuthority).as("externalCaId"),db.ref("type").withSchema(TableName.ExternalCertificateAuthority).as("externalCaType"),+ db.ref("keyAlgorithm").withSchema(TableName.InternalCertificateAuthority).as("internalCaKeyAlgorithm"),db.ref("id").withSchema(TableName.PkiCertificatePolicy).as("policyId"),db.ref("projectId").withSchema(TableName.PkiCertificatePolicy).as("policyProjectId"),db.ref("name").withSchema(TableName.PkiCertificatePolicy).as("policyName"),@@ -277,7 +283,8 @@ export const certificateProfileDALFactory = (db: TDbClient) => {status: result.caStatus,name: result.caName,isExternal: !!result.externalCaId,- externalType: result.externalCaType as string | undefined+ externalType: result.externalCaType as string | undefined,+ keyAlgorithm: result.internalCaKeyAlgorithm as string | null} as TCertificateProfileWithConfigs["certificateAuthority"]): undefined;@@ -404,6 +411,11 @@ export const certificateProfileDALFactory = (db: TDbClient) => {`${TableName.CertificateAuthority}.id`,`${TableName.ExternalCertificateAuthority}.caId`)+ .leftJoin(+ TableName.InternalCertificateAuthority,+ `${TableName.CertificateAuthority}.id`,+ `${TableName.InternalCertificateAuthority}.caId`+ ).leftJoin(TableName.PkiEstEnrollmentConfig,`${TableName.PkiCertificateProfile}.estConfigId`,@@ -431,6 +443,7 @@ export const certificateProfileDALFactory = (db: TDbClient) => {db.ref("status").withSchema(TableName.CertificateAuthority).as("caStatus"),db.ref("id").withSchema(TableName.ExternalCertificateAuthority).as("externalCaId"),db.ref("type").withSchema(TableName.ExternalCertificateAuthority).as("externalCaType"),+ db.ref("keyAlgorithm").withSchema(TableName.InternalCertificateAuthority).as("internalCaKeyAlgorithm"),db.ref("id").withSchema(TableName.PkiEstEnrollmentConfig).as("estId"),db.ref("disableBootstrapCaValidation")@@ -525,7 +538,8 @@ export const certificateProfileDALFactory = (db: TDbClient) => {name: result.caName as string,status: result.caStatus as string,isExternal: !!result.externalCaId,- externalType: result.externalCaType as string | undefined+ externalType: result.externalCaType as string | undefined,+ keyAlgorithm: result.internalCaKeyAlgorithm as string | null}: undefined;diff --git a/backend/src/services/certificate-profile/certificate-profile-service.ts b/backend/src/services/certificate-profile/certificate-profile-service.tsindex cd43d5981b..d51f32116c 100644--- a/backend/src/services/certificate-profile/certificate-profile-service.ts+++ b/backend/src/services/certificate-profile/certificate-profile-service.ts@@ -33,6 +33,7 @@ import { TCertificateAuthorityDALFactory } from "../certificate-authority/certifimport { CaType } from "../certificate-authority/certificate-authority-enums";import { TCertificateAuthoritySecretDALFactory } from "../certificate-authority/certificate-authority-secret-dal";import { TExternalCertificateAuthorityDALFactory } from "../certificate-authority/external-certificate-authority-dal";+import { isSignatureAlgorithmCompatibleWithCaKey } from "../certificate-common/certificate-issuance-utils";import { TCertificatePolicyDALFactory } from "../certificate-policy/certificate-policy-dal";import { TCertificatePolicyServiceFactory } from "../certificate-policy/certificate-policy-service";import { TCertificateRequest } from "../certificate-policy/certificate-policy-types";@@ -92,6 +93,29 @@ const validateIssuerTypeConstraints = (}};+/**+ * A default the issuing CA cannot sign is worse than an invalid request: it is stored, and then every+ * request that omits a signature algorithm inherits it and fails at issuance.+ */+const validateDefaultSignatureAlgorithmAgainstCa = async (+ signatureAlgorithm: string | undefined,+ caId: string | null | undefined,+ certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory, "findByIdWithAssociatedCa">+) => {+ if (!signatureAlgorithm || !caId) return;++ const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(caId);+ const caKeyAlgorithm = ca?.internalCa?.keyAlgorithm;+ // External CAs pick their own signing key, so there is nothing to check against here.+ if (!caKeyAlgorithm) return;++ if (!isSignatureAlgorithmCompatibleWithCaKey(signatureAlgorithm, caKeyAlgorithm)) {+ throw new BadRequestError({+ message: `Default signature algorithm ${signatureAlgorithm} is not compatible with the certificate authority's ${caKeyAlgorithm} key`+ });+ }+};+const validateTemplateByExternalCaType = (externalCaType: CaType | undefined,externalConfigs: Record<string, unknown> | null | undefined@@ -465,6 +489,12 @@ export const certificateProfileServiceFactory = ({}}+ await validateDefaultSignatureAlgorithmAgainstCa(+ data.defaults?.signatureAlgorithm,+ data.caId,+ certificateAuthorityDAL+ );+// Validate external configsawait validateExternalConfigs(data.externalConfigs,@@ -776,6 +806,12 @@ export const certificateProfileServiceFactory = ({}}+ await validateDefaultSignatureAlgorithmAgainstCa(+ data.defaults?.signatureAlgorithm,+ finalCaId,+ certificateAuthorityDAL+ );+const updatedData =finalIssuerType === IssuerType.SELF_SIGNED && existingProfile.caId ? { ...data, caId: null } : data;diff --git a/backend/src/services/certificate-profile/certificate-profile-types.ts b/backend/src/services/certificate-profile/certificate-profile-types.tsindex e1febfb034..a65ca4847a 100644--- a/backend/src/services/certificate-profile/certificate-profile-types.ts+++ b/backend/src/services/certificate-profile/certificate-profile-types.ts@@ -104,6 +104,7 @@ export type TCertificateProfileWithConfigs = TCertificateProfile & {name: string;isExternal?: boolean;externalType?: string;+ keyAlgorithm?: string | null;};certificatePolicy?: {id: string;diff --git a/frontend/src/hooks/api/certificateProfiles/types.ts b/frontend/src/hooks/api/certificateProfiles/types.tsindex 8aa385f848..b0bb7275e7 100644--- a/frontend/src/hooks/api/certificateProfiles/types.ts+++ b/frontend/src/hooks/api/certificateProfiles/types.ts@@ -55,6 +55,7 @@ export type TCertificateProfile = {name: string;isExternal?: boolean;externalType?: string | null;+ keyAlgorithm?: string | null;};};@@ -66,6 +67,7 @@ export type TCertificateProfileWithDetails = TCertificateProfile & {name: string;isExternal?: boolean;externalType?: string | null;+ keyAlgorithm?: string | null;};certificatePolicy?: {id: string;diff --git a/frontend/src/hooks/api/certificates/constants.tsx b/frontend/src/hooks/api/certificates/constants.tsxindex 9c55b1d272..674e5bc65e 100644--- a/frontend/src/hooks/api/certificates/constants.tsx+++ b/frontend/src/hooks/api/certificates/constants.tsx@@ -121,6 +121,44 @@ export const buildExtendedKeyUsageToggleSchema = <T,>(field: T) =>T>;+const getSignatureAlgorithmFamily = (signatureAlgorithm: string): string => {+ if (signatureAlgorithm.startsWith("ML-DSA")) return "ML-DSA";+ if (signatureAlgorithm.startsWith("SLH-DSA")) return "SLH-DSA";+ return signatureAlgorithm.split("-")[0];+};++const getCaKeyAlgorithmFamily = (caKeyAlgorithm: string): string | null => {+ if (caKeyAlgorithm.startsWith("RSA")) return "RSA";+ if (caKeyAlgorithm.startsWith("EC")) return "ECDSA";+ if (caKeyAlgorithm.startsWith("ML-DSA")) return "ML-DSA";+ if (caKeyAlgorithm.startsWith("SLH-DSA")) return "SLH-DSA";+ return null;+};++// Mirrors the CA signature check in the backend internal CA service. Keep both in sync.+export const getCaSignatureIncompatibilityReason = (+ signatureAlgorithm: string,+ caKeyAlgorithm?: string | null+): string | undefined => {+ if (!caKeyAlgorithm) return undefined;++ const caFamily = getCaKeyAlgorithmFamily(caKeyAlgorithm);+ if (!caFamily) return undefined;++ const caKeyName =+ (certKeyAlgorithmToNameMap as Record<string, string | undefined>)[caKeyAlgorithm] ??+ caKeyAlgorithm;++ if (caFamily === "ML-DSA" || caFamily === "SLH-DSA") {+ if (signatureAlgorithm === caKeyAlgorithm) return undefined;+ return `Incompatible with the profile's CA. Its ${caKeyName} key can only sign with ${caKeyName}.`;+ }++ if (getSignatureAlgorithmFamily(signatureAlgorithm) === caFamily) return undefined;++ return `Incompatible with the profile's CA. Its ${caKeyName} key can only sign ${caFamily} signature algorithms.`;+};+export const SIGNATURE_ALGORITHMS_OPTIONS = [{ value: "RSA-SHA256", label: "RSA-SHA256" },{ value: "RSA-SHA384", label: "RSA-SHA384" },diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/AlgorithmSelectors.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/AlgorithmSelectors.tsxindex aa48f774e9..f7408cfe9e 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/AlgorithmSelectors.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/AlgorithmSelectors.tsx@@ -11,10 +11,16 @@ import {SelectContent,SelectItem,SelectTrigger,- SelectValue+ SelectValue,+ Tooltip,+ TooltipContent,+ TooltipTrigger} from "@app/components/v3";import { useSubscription } from "@app/context";-import { isPqcAlgorithm } from "@app/hooks/api/certificates/constants";+import {+ getCaSignatureIncompatibilityReason,+ isPqcAlgorithm+} from "@app/hooks/api/certificates/constants";type AlgorithmOption = {value: string;@@ -23,6 +29,58 @@ type AlgorithmOption = {const NONE_VALUE = "__none__";+type AlgorithmOptionsProps = {+ options: AlgorithmOption[];+ nonePlaceholder?: string;+ caKeyAlgorithm?: string | null;+};++const AlgorithmOptions = ({ options, nonePlaceholder, caKeyAlgorithm }: AlgorithmOptionsProps) => {+ const { subscription } = useSubscription();++ return (+ <>+ {nonePlaceholder && <SelectItem value={NONE_VALUE}>{nonePlaceholder}</SelectItem>}+ {options.map((algorithm) => {+ const isGated = isPqcAlgorithm(algorithm.value) && !subscription?.pkiPqc;+ const incompatibilityReason = isGated+ ? undefined+ : getCaSignatureIncompatibilityReason(algorithm.value, caKeyAlgorithm);++ const item = (+ <SelectItem+ key={algorithm.value}+ value={algorithm.value}+ disabled={isGated || Boolean(incompatibilityReason)}+ >+ <span className="flex items-center gap-2">+ {algorithm.label}+ {isGated && <Badge variant="info">Enterprise</Badge>}+ </span>+ </SelectItem>+ );++ if (!incompatibilityReason) return item;++ return (+ <Tooltip key={algorithm.value}>+ <TooltipTrigger asChild>+ {/* The disabled item drops pointer events, so the wrapper carries the hover. */}+ {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}+ <span tabIndex={0} className="block">+ {item}+ </span>+ </TooltipTrigger>+ <TooltipContent side="right" className="max-w-64">+ {incompatibilityReason}+ </TooltipContent>+ </Tooltip>+ );+ })}+ </>+ );+};+type AlgorithmSelectProps = {control: Control<any>;name: string;@@ -33,7 +91,7 @@ type AlgorithmSelectProps = {isRequired: boolean;nonePlaceholder?: string;selectPlaceholder: string;- renderOptions: (options: AlgorithmOption[]) => ReactNode;+ children: ReactNode;disabledReason?: string;};@@ -47,7 +105,7 @@ const AlgorithmSelect = ({isRequired,nonePlaceholder,selectPlaceholder,- renderOptions,+ children,disabledReason}: AlgorithmSelectProps) => (<Controller@@ -73,7 +131,7 @@ const AlgorithmSelect = ({</span>)}</SelectTrigger>- <SelectContent position="popper">{renderOptions(options)}</SelectContent>+ <SelectContent position="popper">{children}</SelectContent></Select>{disabledReason && <FieldDescription>{disabledReason}</FieldDescription>}<FieldError>{error}</FieldError>@@ -97,6 +155,7 @@ type AlgorithmSelectorsProps = {keyAlgorithmDisabledReason?: string;keyAlgorithmRequired?: boolean;keyAlgorithmPlaceholder?: string;+ caKeyAlgorithm?: string | null;};export const AlgorithmSelectors = ({@@ -113,57 +172,43 @@ export const AlgorithmSelectors = ({hideSignatureAlgorithm = false,keyAlgorithmDisabledReason,keyAlgorithmRequired = isRequired,- keyAlgorithmPlaceholder = "Select key algorithm"-}: AlgorithmSelectorsProps) => {- const { subscription } = useSubscription();-- const renderOptions = (options: AlgorithmOption[]): ReactNode => (- <>- {nonePlaceholder && <SelectItem value={NONE_VALUE}>{nonePlaceholder}</SelectItem>}- {options.map((algorithm) => {- const isGated = isPqcAlgorithm(algorithm.value) && !subscription?.pkiPqc;- return (- <SelectItem key={algorithm.value} value={algorithm.value} disabled={isGated}>- <span className="flex items-center gap-2">- {algorithm.label}- {isGated && <Badge variant="info">Enterprise</Badge>}- </span>- </SelectItem>- );- })}- </>- );-- return (- <div className={hideSignatureAlgorithm ? "grid grid-cols-1 gap-4" : "grid grid-cols-2 gap-4"}>- {!hideSignatureAlgorithm && (- <AlgorithmSelect- control={control}- name={signatureFieldName}- label="Signature Algorithm"- options={availableSignatureAlgorithms}- error={signatureError}- shouldUnregister={shouldUnregister}- isRequired={isRequired}- nonePlaceholder={nonePlaceholder}- selectPlaceholder="Select signature algorithm"- renderOptions={renderOptions}- />- )}-+ keyAlgorithmPlaceholder = "Select key algorithm",+ caKeyAlgorithm+}: AlgorithmSelectorsProps) => (+ <div className={hideSignatureAlgorithm ? "grid grid-cols-1 gap-4" : "grid grid-cols-2 gap-4"}>+ {!hideSignatureAlgorithm && (<AlgorithmSelectcontrol={control}- name={keyFieldName}- label="Key Algorithm"- options={availableKeyAlgorithms}- error={keyError}+ name={signatureFieldName}+ label="Signature Algorithm"+ options={availableSignatureAlgorithms}+ error={signatureError}shouldUnregister={shouldUnregister}- isRequired={keyAlgorithmRequired}+ isRequired={isRequired}nonePlaceholder={nonePlaceholder}- selectPlaceholder={keyAlgorithmPlaceholder}- renderOptions={renderOptions}- disabledReason={keyAlgorithmDisabledReason}- />- </div>- );-};+ selectPlaceholder="Select signature algorithm"+ >+ <AlgorithmOptions+ options={availableSignatureAlgorithms}+ nonePlaceholder={nonePlaceholder}+ caKeyAlgorithm={caKeyAlgorithm}+ />+ </AlgorithmSelect>+ )}++ <AlgorithmSelect+ control={control}+ name={keyFieldName}+ label="Key Algorithm"+ options={availableKeyAlgorithms}+ error={keyError}+ shouldUnregister={shouldUnregister}+ isRequired={keyAlgorithmRequired}+ nonePlaceholder={nonePlaceholder}+ selectPlaceholder={keyAlgorithmPlaceholder}+ disabledReason={keyAlgorithmDisabledReason}+ >+ <AlgorithmOptions options={availableKeyAlgorithms} nonePlaceholder={nonePlaceholder} />+ </AlgorithmSelect>+ </div>+);diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsxindex 1b3a79af5e..cd1db176a8 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx@@ -771,6 +771,7 @@ export const CertificateIssuanceModal = ({control={control}availableSignatureAlgorithms={availableSignatureAlgorithms}availableKeyAlgorithms={availableKeyAlgorithms}+ caKeyAlgorithm={actualSelectedProfile?.certificateAuthority?.keyAlgorithm}hideSignatureAlgorithm={isAdcsProfile}signatureError={(formState.errors as { signatureAlgorithm?: { message?: string } })diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsxindex bff33a15d7..9cce703ac3 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx@@ -24,6 +24,7 @@ import { IssuerType, useGetCertificateProfileById } from "@app/hooks/api/certifiimport {certKeyAlgorithms,EXTENDED_KEY_USAGES_OPTIONS,+ getCaSignatureIncompatibilityReason,KEY_USAGES_OPTIONS,SIGNATURE_ALGORITHMS_OPTIONS} from "@app/hooks/api/certificates/constants";@@ -310,6 +311,18 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTog[availableSignatureAlgorithms, watchedSignatureAlgorithm]);+ const caKeyAlgorithm = profile?.certificateAuthority?.keyAlgorithm;++ // The form seeds this from the existing certificate, which the same fixed CA signed, so a mismatch+ // should be unreachable. Kept as a guard because the seeded value is submitted untouched by default,+ // and the field asking again beats posting one the CA is guaranteed to reject.+ useEffect(() => {+ if (!isOpen || !watchedSignatureAlgorithm) return;+ if (getCaSignatureIncompatibilityReason(watchedSignatureAlgorithm, caKeyAlgorithm)) {+ setValue("signatureAlgorithm", "");+ }+ }, [isOpen, watchedSignatureAlgorithm, caKeyAlgorithm, setValue]);+const selectableSubjectAttributeTypes = useMemo(() =>Array.from(@@ -613,6 +626,7 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTogcontrol={control}availableSignatureAlgorithms={selectableSignatureAlgorithms}availableKeyAlgorithms={selectableKeyAlgorithms}+ caKeyAlgorithm={caKeyAlgorithm}keyAlgorithmDisabledReason={keySource === CertificateRenewalKeySource.Reuse? "The key algorithm is fixed while the existing key pair is reused."diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts b/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.tsindex c387ca30d2..59eff2c12b 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts@@ -4,6 +4,7 @@ import { UseFormSetValue, UseFormWatch } from "react-hook-form";import {certKeyAlgorithms,EXTENDED_KEY_USAGES_OPTIONS,+ getCaSignatureIncompatibilityReason,KEY_USAGES_OPTIONS,SIGNATURE_ALGORITHMS_OPTIONS} from "@app/hooks/api/certificates/constants";@@ -383,6 +384,21 @@ export const useCertificatePolicy = (}}, [templateData, selectedProfile, setValue, watch, isModalOpen]);+ const caKeyAlgorithm = selectedProfile?.certificateAuthority?.keyAlgorithm as+ | string+ | null+ | undefined;+ const selectedSignatureAlgorithm = watch("signatureAlgorithm") as string | undefined;++ // The issuing CA can only sign with its own key family, so a selection carried over from a+ // previously selected profile has to go rather than fail validation at issuance.+ useEffect(() => {+ if (!isModalOpen || !selectedSignatureAlgorithm) return;+ if (getCaSignatureIncompatibilityReason(selectedSignatureAlgorithm, caKeyAlgorithm)) {+ setValue("signatureAlgorithm", "");+ }+ }, [isModalOpen, selectedSignatureAlgorithm, caKeyAlgorithm, setValue]);+useEffect(() => {if (!isModalOpen || !selectedProfile) return;const defaults = selectedProfile?.defaults;@@ -390,7 +406,8 @@ export const useCertificatePolicy = (if (defaults.signatureAlgorithm &&- availableSignatureAlgorithms.some((opt) => opt.value === defaults.signatureAlgorithm)+ availableSignatureAlgorithms.some((opt) => opt.value === defaults.signatureAlgorithm) &&+ !getCaSignatureIncompatibilityReason(defaults.signatureAlgorithm, caKeyAlgorithm)) {setValue("signatureAlgorithm", defaults.signatureAlgorithm);}@@ -405,6 +422,7 @@ export const useCertificatePolicy = (selectedProfile,availableSignatureAlgorithms,availableKeyAlgorithms,+ caKeyAlgorithm,setValue]);diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsxindex fc45414ff5..651fc76d27 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx@@ -660,6 +660,9 @@ export const CreateProfileModal = ({}, [selectedPolicyData]);const selectedCa = certificateAuthorities.find((ca) => ca.id === watchedCertificateAuthorityId);+ // Only internal CAs sign with a key Infisical holds; an external CA's signing key is its own concern.+ const caKeyAlgorithm =+ selectedCa?.type === CaType.INTERNAL ? selectedCa.configuration.keyAlgorithm : undefined;const isAzureAdcsCa = selectedCa?.type === CaType.AZURE_AD_CS;const isAdcsCa = selectedCa?.type === CaType.ADCS;// ACM Public CA issues certificates with a fixed 198-day validity, so pin the TTL default.@@ -1139,6 +1142,7 @@ export const CreateProfileModal = ({policyConstraints={policyConstraints}isAwsAcmPublicCa={isAwsAcmPublicCa}isExternalAdcsCa={isAzureAdcsCa || isAdcsCa}+ caKeyAlgorithm={caKeyAlgorithm}/>)}</div>diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal/ProfileDefaultsStep.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal/ProfileDefaultsStep.tsxindex 458c177313..9ef318adc2 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal/ProfileDefaultsStep.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal/ProfileDefaultsStep.tsx@@ -1,4 +1,4 @@-import { useMemo } from "react";+import { useEffect, useMemo } from "react";import { Control, Controller, UseFormSetValue, UseFormWatch } from "react-hook-form";import { FileBadge, Plus, Trash2 } from "lucide-react";@@ -20,10 +20,14 @@ import {SelectContent,SelectItem,SelectTrigger,- SelectValue+ SelectValue,+ Tooltip,+ TooltipContent,+ TooltipTrigger} from "@app/components/v3";import {EXTENDED_KEY_USAGES_OPTIONS,+ getCaSignatureIncompatibilityReason,KEY_USAGES_OPTIONS} from "@app/hooks/api/certificates/constants";import {@@ -234,6 +238,7 @@ type Props = {policyConstraints: PolicyConstraints;isAwsAcmPublicCa: boolean;isExternalAdcsCa: boolean;+ caKeyAlgorithm?: string | null;};const EXTERNAL_ADCS_HINT =@@ -245,7 +250,8 @@ export const ProfileDefaultsStep = ({setValue,policyConstraints,isAwsAcmPublicCa,- isExternalAdcsCa+ isExternalAdcsCa,+ caKeyAlgorithm}: Props) => {const watchedPolicyId = watch("certificatePolicyId");const watchedDefaultsIsCA = watch("defaults.basicConstraints.isCA") || false;@@ -254,6 +260,15 @@ export const ProfileDefaultsStep = ({const watchedDefaultSigAlg = watch("defaults.signatureAlgorithm") ?? null;const watchedDefaultKeyAlg = watch("defaults.keyAlgorithm") ?? null;const watchedDefaultKeyUsages = watch("defaults.keyUsages") || {};++ // A default the issuing CA cannot sign would fail every request that relies on it, so drop it+ // rather than persist a value that is guaranteed to break issuance.+ useEffect(() => {+ if (!watchedDefaultSigAlg) return;+ if (getCaSignatureIncompatibilityReason(watchedDefaultSigAlg, caKeyAlgorithm)) {+ setValue("defaults.signatureAlgorithm", null);+ }+ }, [watchedDefaultSigAlg, caKeyAlgorithm, setValue]);const watchedDefaultExtKeyUsages = watch("defaults.extendedKeyUsages") || {};const filteredKeyUsages = useMemo(@@ -407,11 +422,39 @@ export const ProfileDefaultsStep = ({</SelectTrigger><SelectContent position="popper"><SelectItem value={NO_DEFAULT}>No default</SelectItem>- {policyConstraints.allowedSignatureAlgorithms.map((option) => (- <SelectItem key={option.value} value={option.value}>- {option.label}- </SelectItem>- ))}+ {policyConstraints.allowedSignatureAlgorithms.map((option) => {+ const incompatibilityReason = getCaSignatureIncompatibilityReason(+ option.value,+ caKeyAlgorithm+ );++ const item = (+ <SelectItem+ key={option.value}+ value={option.value}+ disabled={Boolean(incompatibilityReason)}+ >+ {option.label}+ </SelectItem>+ );++ if (!incompatibilityReason) return item;++ return (+ <Tooltip key={option.value}>+ <TooltipTrigger asChild>+ {/* The disabled item drops pointer events, so the wrapper carries the hover. */}+ {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}+ <span tabIndex={0} className="block">+ {item}+ </span>+ </TooltipTrigger>+ <TooltipContent side="right" className="max-w-64">+ {incompatibilityReason}+ </TooltipContent>+ </Tooltip>+ );+ })}</SelectContent></Select></FieldContent>