Skip to content

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

Address greptile comments

Carlos Monastyrskic45274af93e0
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 6ac0d24e1a..42564e63ae 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -5148,11 +5148,13 @@ interface ImportPkiSignerCertificateEvent {
signerId: string;
name: string;
caId: string;
+ caName: string;
externalOrderId: string;
certificateId?: string | null;
commonName?: string;
keyAlgorithm?: string;
hsmConnectorId: string;
+ hsmConnectorName: string;
hsmKeyLabel: string;
hsmKeyId?: string;
certificateRenewBeforeDays?: number | null;
diff --git a/backend/src/server/routes/v1/signer-routers/certificate-router.ts b/backend/src/server/routes/v1/signer-routers/certificate-router.ts
index 9c33673ce0..9e1fe1a1f1 100644
--- a/backend/src/server/routes/v1/signer-routers/certificate-router.ts
+++ b/backend/src/server/routes/v1/signer-routers/certificate-router.ts
@@ -93,6 +93,53 @@ export const registerSignerCertificateRouter = async (server: FastifyZodProvider
}
});
+ server.route({
+ method: "POST",
+ url: "/check-certificate-import",
+ config: { rateLimit: readLimit },
+ schema: {
+ hide: true,
+ operationId: "checkSignerCertificateImport",
+ tags: [ApiDocsTags.PkiSigners],
+ description:
+ "Check that the HSM private key matches the certificate in an existing DigiCert order, without creating or changing a signer.",
+ body: z.object({
+ caId: z.string().uuid().describe("The DigiCert certificate authority the order belongs to."),
+ externalOrderId: ExternalOrderIdSchema.describe("The DigiCert order whose certificate to check."),
+ certificate: SignerCertificateInputSchema.pick({
+ hsmConnectorId: true,
+ hsmKeyLabel: true,
+ hsmKeyId: true
+ }).required({ hsmConnectorId: true, hsmKeyLabel: true })
+ }),
+ response: {
+ 200: z.object({
+ check: z.object({
+ hsmKeyId: z
+ .string()
+ .nullable()
+ .describe("The hex-encoded CKA_ID of the matching key, when the HSM reports one."),
+ commonName: z.string(),
+ certificateTtlDays: z.number(),
+ keyAlgorithm: z.string()
+ })
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.OAUTH]),
+ handler: async (req) => {
+ const check = await server.services.pkiSigner.checkCertificateImport({
+ projectId: req.internalCertManagerProjectId,
+ ...req.body,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
+ });
+ return { check };
+ }
+ });
+
server.route({
method: "POST",
url: "/:signerId/certificate/import",
@@ -127,7 +174,7 @@ export const registerSignerCertificateRouter = async (server: FastifyZodProvider
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),
handler: async (req) => {
- const signer = await server.services.pkiSigner.importCertificate({
+ const { signer, caName, hsmConnectorName } = await server.services.pkiSigner.importCertificate({
signerId: req.params.signerId,
...req.body,
actor: req.permission.type,
@@ -145,11 +192,13 @@ export const registerSignerCertificateRouter = async (server: FastifyZodProvider
signerId: signer.id,
name: signer.name,
caId: req.body.caId,
+ caName,
externalOrderId: req.body.externalOrderId,
certificateId: signer.certificateId,
commonName: signer.commonName ?? undefined,
keyAlgorithm: signer.keyAlgorithm ?? undefined,
hsmConnectorId: req.body.certificate.hsmConnectorId,
+ hsmConnectorName,
hsmKeyLabel: req.body.certificate.hsmKeyLabel,
hsmKeyId: req.body.certificate.hsmKeyId,
certificateRenewBeforeDays: signer.certificateRenewBeforeDays
diff --git a/backend/src/services/hsm-connector/hsm-connector-service.ts b/backend/src/services/hsm-connector/hsm-connector-service.ts
index 2f50994c50..8c1be0a1a0 100644
--- a/backend/src/services/hsm-connector/hsm-connector-service.ts
+++ b/backend/src/services/hsm-connector/hsm-connector-service.ts
@@ -562,6 +562,11 @@ export const hsmConnectorServiceFactory = ({
message: "The HSM Connector's gateway is too old to look up keys. Update the gateway to the latest version."
});
}
+ if (isPkcs11Error(err, Pkcs11ErrorCode.BadRequest)) {
+ throw new BadRequestError({
+ message: `Too many private keys in the HSM Connector's slot have the label '${dto.keyLabel}'. Give the keys unique labels.`
+ });
+ }
throw err;
});
return { keys: result.keys };
diff --git a/backend/src/services/signer/signer-dal.ts b/backend/src/services/signer/signer-dal.ts
index 5e3f478108..8c5427f546 100644
--- a/backend/src/services/signer/signer-dal.ts
+++ b/backend/src/services/signer/signer-dal.ts
@@ -177,6 +177,14 @@ export const signerDALFactory = (db: TDbClient) => {
}
};
+ const findByIdForUpdate = async (signerId: string, tx: Knex): Promise<TPkiSigners | undefined> => {
+ try {
+ return (await tx(TableName.PkiSigners).where({ id: signerId }).forUpdate().first()) as TPkiSigners | undefined;
+ } catch (error) {
+ throw new DatabaseError({ error, name: "FindSignerByIdForUpdate" });
+ }
+ };
+
const findOneInOrgByCurrentHsmPublicKey = async (
projectId: string,
hsmPublicKeySpki: Buffer,
@@ -206,6 +214,7 @@ export const signerDALFactory = (db: TDbClient) => {
findByStatusWithCertificate,
findByProjectId,
countByProjectId,
- findOneInOrgByCurrentHsmPublicKey
+ findOneInOrgByCurrentHsmPublicKey,
+ findByIdForUpdate
};
};
diff --git a/backend/src/services/signer/signer-service.ts b/backend/src/services/signer/signer-service.ts
index d8785bf019..870826761d 100644
--- a/backend/src/services/signer/signer-service.ts
+++ b/backend/src/services/signer/signer-service.ts
@@ -98,6 +98,7 @@ import {
import { TSignerIssuanceServiceFactory } from "./signer-issuance-service";
import {
SignerExternalCaConfigSchema,
+ TCheckCertificateImportDTO,
TCreateSignerDTO,
TDeleteSignerDTO,
TDisableSignerDTO,
@@ -463,13 +464,12 @@ export const signerServiceFactory = ({
return orderId;
};
- const $importExistingDigiCertCertificate = async (input: {
+ const $verifyExistingDigiCertCertificate = async (input: {
caId: string;
projectId: string;
orderId: number;
certificate?: TSignerCertificateInput;
actor: Parameters<typeof hsmConnectorService.assertAttachPermission>[0];
- signerId?: string;
}) => {
const { caId, projectId, orderId } = input;
const hsmConnectorId = input.certificate?.hsmConnectorId;
@@ -481,7 +481,7 @@ export const signerServiceFactory = ({
"Using an existing DigiCert certificate requires an HSM Connector and the label of the certificate's private key on that HSM."
});
}
- await hsmConnectorService.assertAttachPermission(input.actor, hsmConnectorId, projectId);
+ const hsmConnector = await hsmConnectorService.assertAttachPermission(input.actor, hsmConnectorId, projectId);
const { pemBundle, certificate } = await digicertFns.fetchIssuedCodeSigningCertificate(caId, orderId);
const { keyAlgorithm } = extractCertificateAlgorithms(certificate);
@@ -496,15 +496,14 @@ export const signerServiceFactory = ({
{ hsmConnectorId, projectId, hsmKeyLabel, hsmKeyId: requestedHsmKeyId, certificate }
);
- const preparedCertificate = await digicertFns.prepareCodeSigningCertificateImport({ caId, orderId, pemBundle });
-
const validityDays = Math.round(
(certificate.notAfter.getTime() - certificate.notBefore.getTime()) / (24 * 60 * 60 * 1000)
);
return {
orderId,
projectId,
- preparedCertificate,
+ pemBundle,
+ hsmConnectorName: hsmConnector.name,
hsm: {
keySource: CertKeySource.Hsm,
hsmConnectorId,
@@ -518,6 +517,40 @@ export const signerServiceFactory = ({
};
};
+ const $importExistingDigiCertCertificate = async (
+ input: Parameters<typeof $verifyExistingDigiCertCertificate>[0]
+ ) => {
+ const { pemBundle, ...verified } = await $verifyExistingDigiCertCertificate(input);
+ const preparedCertificate = await digicertFns.prepareCodeSigningCertificateImport({
+ caId: input.caId,
+ orderId: input.orderId,
+ pemBundle
+ });
+ return { ...verified, preparedCertificate };
+ };
+
+ const checkCertificateImport = async (dto: TCheckCertificateImportDTO) => {
+ const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(dto.caId);
+ if (!ca || ca.projectId !== dto.projectId) {
+ throw new NotFoundError({ message: `Certificate authority '${dto.caId}' not found in this organization.` });
+ }
+ const caType: CaType = (ca.externalCa?.type as CaType | undefined) ?? CaType.INTERNAL;
+ const orderId = $parseDigiCertOrderId(dto.externalOrderId, caType, "externalOrderId") as number;
+ const verified = await $verifyExistingDigiCertCertificate({
+ caId: ca.id,
+ projectId: dto.projectId,
+ orderId,
+ certificate: { keySource: CertKeySource.Hsm, ...dto.certificate },
+ actor: { type: dto.actor, id: dto.actorId, authMethod: dto.actorAuthMethod, orgId: dto.actorOrgId }
+ });
+ return {
+ hsmKeyId: verified.hsm.hsmKeyId,
+ commonName: verified.commonName,
+ certificateTtlDays: verified.certificateTtlDays,
+ keyAlgorithm: verified.keyAlgorithm
+ };
+ };
+
const $attachImportedCertificate = async (
imported: Awaited<ReturnType<typeof $importExistingDigiCertCertificate>>,
signerId: string | undefined,
@@ -1475,27 +1508,36 @@ export const signerServiceFactory = ({
projectId: signer.projectId,
orderId: importOrderId,
certificate: { keySource: CertKeySource.Hsm, ...dto.certificate },
- actor: { type: dto.actor, id: dto.actorId, authMethod: dto.actorAuthMethod, orgId: dto.actorOrgId },
- signerId: signer.id
+ actor: { type: dto.actor, id: dto.actorId, authMethod: dto.actorAuthMethod, orgId: dto.actorOrgId }
});
- const renewBeforeDays =
- dto.certificateRenewBeforeDays !== undefined ? dto.certificateRenewBeforeDays : signer.certificateRenewBeforeDays;
- if (renewBeforeDays != null && renewBeforeDays >= imported.certificateTtlDays) {
- throw new BadRequestError({
- message: `Renew before (${renewBeforeDays}d) must be less than the validity of the certificate in DigiCert order ${importOrderId} (${imported.certificateTtlDays}d).`
- });
- }
- return signerDAL
+ const assertRenewBeforeFitsImport = (renewBeforeDays?: number | null) => {
+ if (renewBeforeDays != null && renewBeforeDays >= imported.certificateTtlDays) {
+ throw new BadRequestError({
+ message: `Renew before (${renewBeforeDays}d) must be less than the validity of the certificate in DigiCert order ${importOrderId} (${imported.certificateTtlDays}d).`
+ });
+ }
+ };
+ assertRenewBeforeFitsImport(
+ dto.certificateRenewBeforeDays !== undefined ? dto.certificateRenewBeforeDays : signer.certificateRenewBeforeDays
+ );
+ const updatedSigner = await signerDAL
.transaction(async (tx) => {
await signerIssuanceService.cancelOpenJobs(signer.id, importOrderId, tx);
const importedCertificateId = await $attachImportedCertificate(imported, signer.id, tx);
+ const lockedSigner = await signerDAL.findByIdForUpdate(signer.id, tx);
+ if (!lockedSigner) throw new NotFoundError({ message: `Signer with ID '${dto.signerId}' not found` });
+ if (dto.certificateRenewBeforeDays === undefined) {
+ assertRenewBeforeFitsImport(lockedSigner.certificateRenewBeforeDays);
+ }
return signerDAL.updateById(
signer.id,
{
caId: ca.id,
commonName: imported.commonName,
certificateTtlDays: imported.certificateTtlDays,
- certificateRenewBeforeDays: renewBeforeDays,
+ ...(dto.certificateRenewBeforeDays !== undefined
+ ? { certificateRenewBeforeDays: dto.certificateRenewBeforeDays }
+ : {}),
keyAlgorithm: imported.keyAlgorithm,
externalCaConfig: null,
certificateId: importedCertificateId,
@@ -1509,6 +1551,7 @@ export const signerServiceFactory = ({
await $rethrowConcurrentImport(error, imported);
throw error;
});
+ return { signer: updatedSigner, caName: ca.name, hsmConnectorName: imported.hsmConnectorName };
};
const reissueCertificate = async (dto: TReissueCertificateDTO) => {
@@ -2413,6 +2456,7 @@ export const signerServiceFactory = ({
disable,
reissueCertificate,
importCertificate,
+ checkCertificateImport,
exportCertificate,
sign,
getPublicKey,
diff --git a/backend/src/services/signer/signer-types.ts b/backend/src/services/signer/signer-types.ts
index 7e3afe208f..def6a9252f 100644
--- a/backend/src/services/signer/signer-types.ts
+++ b/backend/src/services/signer/signer-types.ts
@@ -151,6 +151,13 @@ export type TImportCertificateDTO = {
certificateRenewBeforeDays?: number | null;
} & TActorPermission;
+export type TCheckCertificateImportDTO = {
+ projectId: string;
+ caId: string;
+ externalOrderId: string;
+ certificate: { hsmConnectorId: string; hsmKeyLabel: string; hsmKeyId?: string };
+} & TActorPermission;
+
export type TExportCertificateDTO = {
signerId: string;
} & TActorPermission;
diff --git a/frontend/src/hooks/api/signers/index.tsx b/frontend/src/hooks/api/signers/index.tsx
index f5067ec942..3ec94d0a90 100644
--- a/frontend/src/hooks/api/signers/index.tsx
+++ b/frontend/src/hooks/api/signers/index.tsx
@@ -3,6 +3,7 @@ export {
useAddSignerGroupMember,
useAddSignerIdentityMember,
useAddSignerUserMembers,
+ useCheckSignerCertificateImport,
useCheckSignerIssuance,
useCreateSigner,
useDeleteSigner,
diff --git a/frontend/src/hooks/api/signers/mutations.tsx b/frontend/src/hooks/api/signers/mutations.tsx
index 1a14493b10..9fbbf4e391 100644
--- a/frontend/src/hooks/api/signers/mutations.tsx
+++ b/frontend/src/hooks/api/signers/mutations.tsx
@@ -3,6 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { createNotification } from "@app/components/notifications";
import { apiRequest } from "@app/config/request";
import { approvalRequestQuery } from "@app/hooks/api/approvalRequests/queries";
+import { ApiErrorTypes } from "@app/hooks/api/types";
import { signerKeys } from "./queries";
import {
@@ -10,6 +11,7 @@ import {
TAddSignerGroupMemberDTO,
TAddSignerIdentityMemberDTO,
TAddSignerUserMembersDTO,
+ TCheckSignerCertificateImportDTO,
TCreateSignerDTO,
TDeleteSignerDTO,
TDisableSignerDTO,
@@ -139,6 +141,18 @@ export const useReissueSignerCertificate = () => {
});
};
+export const useCheckSignerCertificateImport = () =>
+ useMutation<{ hsmKeyId: string | null }, object, TCheckSignerCertificateImportDTO>({
+ mutationFn: async (body) => {
+ const { data } = await apiRequest.post<{ check: { hsmKeyId: string | null } }>(
+ "/api/v1/cert-manager/signers/check-certificate-import",
+ body
+ );
+ return data.check;
+ },
+ meta: { handledErrorCodes: [ApiErrorTypes.BadRequestError, ApiErrorTypes.ConflictError] }
+ });
+
export const useImportSignerCertificate = () => {
const queryClient = useQueryClient();
diff --git a/frontend/src/hooks/api/signers/types.ts b/frontend/src/hooks/api/signers/types.ts
index 717d4865d5..8bec3e7065 100644
--- a/frontend/src/hooks/api/signers/types.ts
+++ b/frontend/src/hooks/api/signers/types.ts
@@ -404,6 +404,11 @@ export type TImportSignerCertificateDTO = {
certificateRenewBeforeDays?: number | null;
};
+export type TCheckSignerCertificateImportDTO = Omit<
+ TImportSignerCertificateDTO,
+ "signerId" | "certificateRenewBeforeDays"
+>;
+
export type TEnableSignerDTO = { signerId: string };
export type TDisableSignerDTO = { signerId: string };
diff --git a/frontend/src/pages/cert-manager/CodeSigningPage/components/CreateSignerWizard/CreateSignerWizard.tsx b/frontend/src/pages/cert-manager/CodeSigningPage/components/CreateSignerWizard/CreateSignerWizard.tsx
index 7685cfd489..b0aafe6607 100644
--- a/frontend/src/pages/cert-manager/CodeSigningPage/components/CreateSignerWizard/CreateSignerWizard.tsx
+++ b/frontend/src/pages/cert-manager/CodeSigningPage/components/CreateSignerWizard/CreateSignerWizard.tsx
@@ -1,6 +1,7 @@
import { useEffect, useMemo, useState } from "react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
+import { AxiosError } from "axios";
import { PenTool } from "lucide-react";
import {
@@ -28,6 +29,7 @@ import {
SignerKeyAlgorithm,
SignerMemberRole,
TSignerExternalConfiguration,
+ useCheckSignerCertificateImport,
useCreateSigner
} from "@app/hooks/api/signers";
import { useGetOrgUsers } from "@app/hooks/api/users";
@@ -80,6 +82,8 @@ export const CreateSignerWizard = ({ isOpen, onOpenChange, projectId }: Props) =
});
const createSigner = useCreateSigner();
+ const checkCertificateImport = useCheckSignerCertificateImport();
+ const [importCheckError, setImportCheckError] = useState<string>();
const caOptions: CaOption[] = useMemo(() => {
const list = cas.data ?? [];
@@ -173,6 +177,11 @@ export const CreateSignerWizard = ({ isOpen, onOpenChange, projectId }: Props) =
});
const selectedCaId = certificateForm.watch("caId");
+ const [watchedKeyLabel, watchedKeyId, watchedConnectorId, watchedOrderMode] =
+ certificateForm.watch(["hsmKeyLabel", "hsmKeyId", "hsmConnectorId", "externalOrderMode"]);
+ useEffect(() => {
+ setImportCheckError(undefined);
+ }, [watchedKeyLabel, watchedKeyId, watchedConnectorId, watchedOrderMode]);
const selectedCa = caOptions.find((o) => o.id === selectedCaId) ?? null;
const caCaps = getCaIssuanceCapabilities(selectedCa?.caType);
@@ -338,6 +347,29 @@ export const CreateSignerWizard = ({ isOpen, onOpenChange, projectId }: Props) =
"hsmKeyId"
]);
if (!ok) return;
+ const values = certificateForm.getValues();
+ if (isUsingExistingCertificate(values) && values.externalOrderId && values.hsmConnectorId) {
+ setSubmitting(true);
+ try {
+ await checkCertificateImport.mutateAsync({
+ caId: values.caId,
+ externalOrderId: values.externalOrderId,
+ certificate: {
+ hsmConnectorId: values.hsmConnectorId,
+ hsmKeyLabel: values.hsmKeyLabel,
+ hsmKeyId: values.hsmKeyId || undefined
+ }
+ });
+ } catch (err) {
+ setImportCheckError(
+ (err as AxiosError<{ message?: string }>)?.response?.data?.message ??
+ "Could not check the key against the certificate."
+ );
+ return;
+ } finally {
+ setSubmitting(false);
+ }
+ }
persistCertificateForm();
setStep(3);
return;
@@ -442,6 +474,7 @@ export const CreateSignerWizard = ({ isOpen, onOpenChange, projectId }: Props) =
minRsaKeyBits={caCaps.minRsaKeyBits}
hsmConnectorOptions={hsmConnectorOptions}
isHsmConnectorsLoading={isHsmConnectorsLoading}
+ importCheckError={importCheckError}
/>
)}
{step === 3 && (
diff --git a/frontend/src/pages/cert-manager/SignerDetailPage/components/EditSignerModal/EditSignerModal.tsx b/frontend/src/pages/cert-manager/SignerDetailPage/components/EditSignerModal/EditSignerModal.tsx
index 03c0934a64..57f3fd2227 100644
--- a/frontend/src/pages/cert-manager/SignerDetailPage/components/EditSignerModal/EditSignerModal.tsx
+++ b/frontend/src/pages/cert-manager/SignerDetailPage/components/EditSignerModal/EditSignerModal.tsx
@@ -133,6 +133,7 @@ export const EditSignerModal = ({ isOpen, onOpenChange, signer }: Props) => {
certificateRenewBeforeDays: signer.certificateRenewBeforeDays ?? null,
commonName: signer.commonName ?? "",
certificateTtlDays: signer.certificateTtlDays ?? 365,
+ currentCertificateTtlDays: signer.certificateTtlDays ?? null,
keySource: currentKeySource,
keyAlgorithm: currentKeyAlgorithm,
hsmConnectorId: currentHsmConnectorId,
@@ -208,6 +209,7 @@ export const EditSignerModal = ({ isOpen, onOpenChange, signer }: Props) => {
certificateRenewBeforeDays: signer.certificateRenewBeforeDays ?? null,
commonName: signer.commonName ?? "",
certificateTtlDays: signer.certificateTtlDays ?? 365,
+ currentCertificateTtlDays: signer.certificateTtlDays ?? null,
keySource: currentKeySource,
keyAlgorithm: currentKeyAlgorithm,
hsmConnectorId: currentHsmConnectorId,
diff --git a/frontend/src/pages/cert-manager/SignerDetailPage/components/EditSignerModal/schemas.ts b/frontend/src/pages/cert-manager/SignerDetailPage/components/EditSignerModal/schemas.ts
index 73117a9ea0..8fb2f40895 100644
--- a/frontend/src/pages/cert-manager/SignerDetailPage/components/EditSignerModal/schemas.ts
+++ b/frontend/src/pages/cert-manager/SignerDetailPage/components/EditSignerModal/schemas.ts
@@ -56,6 +56,7 @@ export const createCertificateSchema = (currentKey: TCurrentSignerKey) =>
.default(null),
commonName: z.string().trim().min(1, "Common Name is required").max(256).optional(),
certificateTtlDays: z.coerce.number().int().min(1).max(3650).optional(),
+ currentCertificateTtlDays: z.number().nullable().optional(),
keySource: z.nativeEnum(CertKeySource).default(CertKeySource.Infisical),
keyAlgorithm: z.nativeEnum(SignerKeyAlgorithm).default(SignerKeyAlgorithm.RSA_2048),
hsmConnectorId: z.string().uuid().optional().nullable(),
@@ -69,11 +70,14 @@ export const createCertificateSchema = (currentKey: TCurrentSignerKey) =>
adcsTemplate: z.string().trim().optional().default("")
})
.refine(
- (data) =>
- data.certificateRenewBeforeDays == null ||
- data.certificateTtlDays == null ||
- Boolean(data.externalOrderId) ||
- data.certificateRenewBeforeDays < data.certificateTtlDays,
+ (data) => {
+ if (data.certificateRenewBeforeDays == null || isUsingExistingCertificate(data))
+ return true;
+ const effectiveTtlDays = data.externalOrderId
+ ? data.currentCertificateTtlDays
+ : data.certificateTtlDays;
+ return effectiveTtlDays == null || data.certificateRenewBeforeDays < effectiveTtlDays;
+ },
{
message: "Renew before must be less than the certificate validity (days).",
path: ["certificateRenewBeforeDays"]
diff --git a/frontend/src/pages/cert-manager/components/SignerKeyStep.tsx b/frontend/src/pages/cert-manager/components/SignerKeyStep.tsx
index 5518a8447f..584e3eebb0 100644
--- a/frontend/src/pages/cert-manager/components/SignerKeyStep.tsx
+++ b/frontend/src/pages/cert-manager/components/SignerKeyStep.tsx
@@ -53,6 +53,7 @@ type SignerKeyStepProps = {
isHsmConnectorsLoading: boolean;
minRsaKeyBits?: number;
currentKeyAlgorithm?: SignerKeyAlgorithm;
+ importCheckError?: string;
};
export const SignerKeyStep = ({
@@ -61,7 +62,8 @@ export const SignerKeyStep = ({
hsmConnectorOptions,
isHsmConnectorsLoading,
minRsaKeyBits,
- currentKeyAlgorithm
+ currentKeyAlgorithm,
+ importCheckError
}: SignerKeyStepProps) => {
const { subscription } = useSubscription();
const isHsmLicensed = Boolean(subscription?.hsm);
@@ -149,6 +151,8 @@ export const SignerKeyStep = ({
"Could not look up the key.";
} else if (matchingHsmKeys?.length === 0) {
hsmKeyLookupProblem = "No private key with this label in the connector's slot.";
+ } else if (importCheckError) {
+ hsmKeyLookupProblem = importCheckError;
}
const visibleHsmKeyLabelError = typedKeyLabel ? undefined : hsmKeyLabelError;