Skip to content

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

feat: add kmip client registration with CSR

Sheen Capadngan1115b66b4e51
diff --git a/backend/src/ee/routes/v1/kmip-router.ts b/backend/src/ee/routes/v1/kmip-router.ts
index 78d82a3850..e120368fce 100644
--- a/backend/src/ee/routes/v1/kmip-router.ts
+++ b/backend/src/ee/routes/v1/kmip-router.ts
@@ -287,16 +287,21 @@ export const registerKmipRouter = async (server: FastifyZodProvider) => {
params: z.object({
id: z.string()
}),
- body: z.object({
- keyAlgorithm: z.nativeEnum(CertKeyAlgorithm),
- ttl: z.string().refine((val) => ms(val) > 0, "TTL must be a positive number")
- }),
+ body: z
+ .object({
+ keyAlgorithm: z.nativeEnum(CertKeyAlgorithm).optional(),
+ ttl: z.string().refine((val) => ms(val) > 0, "TTL must be a positive number"),
+ csr: z.string().trim().min(1, "CSR cannot be empty").optional()
+ })
+ .refine((data) => data.csr || data.keyAlgorithm, {
+ message: "Either csr or keyAlgorithm must be provided"
+ }),
response: {
200: z.object({
serialNumber: z.string(),
certificateChain: z.string(),
certificate: z.string(),
- privateKey: z.string()
+ privateKey: z.string().optional()
})
}
},
@@ -321,7 +326,8 @@ export const registerKmipRouter = async (server: FastifyZodProvider) => {
clientId: req.params.id,
serialNumber: certificate.serialNumber,
ttl: req.body.ttl,
- keyAlgorithm: req.body.keyAlgorithm
+ keyAlgorithm: req.body.keyAlgorithm,
+ isFromCsr: Boolean(req.body.csr)
}
}
});
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 2179d4b357..eb0d583bbe 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -5005,8 +5005,9 @@ interface CreateKmipClientCertificateEvent {
metadata: {
clientId: string;
ttl: string;
- keyAlgorithm: string;
+ keyAlgorithm?: string;
serialNumber: string;
+ isFromCsr: boolean;
};
}
diff --git a/backend/src/ee/services/kmip/kmip-service.ts b/backend/src/ee/services/kmip/kmip-service.ts
index 43a439fe2f..786495b9d9 100644
--- a/backend/src/ee/services/kmip/kmip-service.ts
+++ b/backend/src/ee/services/kmip/kmip-service.ts
@@ -12,8 +12,10 @@ import { constructPemChainFromCerts } from "@app/services/certificate/certificat
import { CertExtendedKeyUsage, CertKeyAlgorithm, CertKeyUsage } from "@app/services/certificate/certificate-types";
import {
createSerialNumber,
+ extractDnParts,
keyAlgorithmToAlgCfg
} from "@app/services/certificate-authority/certificate-authority-fns";
+import { extractAlgorithmsFromCSR } from "@app/services/certificate-common/certificate-csr-utils";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
@@ -429,7 +431,8 @@ export const kmipServiceFactory = ({
actorAuthMethod,
ttl,
keyAlgorithm,
- clientId
+ clientId,
+ csr
}: TCreateKmipClientCertificateDTO) => {
const kmipClient = await kmipClientDAL.findById(clientId);
@@ -482,24 +485,6 @@ export const kmipServiceFactory = ({
throw new BadRequestError({ message: "notAfter date is after CA certificate's notAfter date" });
}
- const alg = keyAlgorithmToAlgCfg(keyAlgorithm);
- const leafKeys = await crypto.nativeCrypto.subtle.generateKey(alg, true, ["sign", "verify"]);
-
- const extensions: x509.Extension[] = [
- new x509.BasicConstraintsExtension(false),
- await x509.AuthorityKeyIdentifierExtension.create(caCertObj, false),
- await x509.SubjectKeyIdentifierExtension.create(leafKeys.publicKey),
- new x509.CertificatePolicyExtension(["2.5.29.32.0"]), // anyPolicy
- new x509.KeyUsagesExtension(
- // eslint-disable-next-line no-bitwise
- x509.KeyUsageFlags[CertKeyUsage.DIGITAL_SIGNATURE] |
- x509.KeyUsageFlags[CertKeyUsage.KEY_ENCIPHERMENT] |
- x509.KeyUsageFlags[CertKeyUsage.KEY_AGREEMENT],
- true
- ),
- new x509.ExtendedKeyUsageExtension([x509.ExtendedKeyUsage[CertExtendedKeyUsage.CLIENT_AUTH]], true)
- ];
-
const caAlg = keyAlgorithmToAlgCfg(orgKmipCAs.config.caKeyAlgorithm as CertKeyAlgorithm);
const caSkObj = crypto.nativeCrypto.createPrivateKey({
@@ -517,26 +502,108 @@ export const kmipServiceFactory = ({
);
const serialNumber = createSerialNumber();
- const leafCert = await x509.X509CertificateGenerator.create({
- serialNumber,
- subject: `OU=${kmipClient.projectId},CN=${clientId}`,
- issuer: caCertObj.subject,
- notBefore: notBeforeDate,
- notAfter: notAfterDate,
- signingKey: caPrivateKey,
- publicKey: leafKeys.publicKey,
- signingAlgorithm: alg,
- extensions
- });
-
- const skLeafObj = crypto.nativeCrypto.KeyObject.from(leafKeys.privateKey);
+ let leafCert: x509.X509Certificate;
+ let effectiveKeyAlgorithm: CertKeyAlgorithm;
+ let privateKeyPem: string | undefined;
+
+ if (csr) {
+ // CSR mode - sign the provided CSR
+ const csrObj = new x509.Pkcs10CertificateRequest(csr);
+
+ // Validate CSR signature
+ const isValid = await csrObj.verify();
+ if (!isValid) {
+ throw new BadRequestError({ message: "Invalid CSR signature" });
+ }
+
+ // Extract key algorithm from CSR
+ const { keyAlgorithm: csrKeyAlgorithm } = extractAlgorithmsFromCSR(csr);
+ effectiveKeyAlgorithm = csrKeyAlgorithm;
+
+ // Extract additional subject fields from CSR (O, L, ST, C)
+ const dn = extractDnParts(csrObj.subjectName);
+ const subjectParts = [`OU=${kmipClient.projectId}`, `CN=${clientId}`];
+ if (dn.organization) subjectParts.push(`O=${dn.organization}`);
+ if (dn.locality) subjectParts.push(`L=${dn.locality}`);
+ if (dn.province) subjectParts.push(`ST=${dn.province}`);
+ if (dn.country) subjectParts.push(`C=${dn.country}`);
+ const subject = subjectParts.join(",");
+
+ const extensions: x509.Extension[] = [
+ new x509.BasicConstraintsExtension(false),
+ await x509.AuthorityKeyIdentifierExtension.create(caCertObj, false),
+ await x509.SubjectKeyIdentifierExtension.create(csrObj.publicKey),
+ new x509.CertificatePolicyExtension(["2.5.29.32.0"]), // anyPolicy
+ new x509.KeyUsagesExtension(
+ // eslint-disable-next-line no-bitwise
+ x509.KeyUsageFlags[CertKeyUsage.DIGITAL_SIGNATURE] |
+ x509.KeyUsageFlags[CertKeyUsage.KEY_ENCIPHERMENT] |
+ x509.KeyUsageFlags[CertKeyUsage.KEY_AGREEMENT],
+ true
+ ),
+ new x509.ExtendedKeyUsageExtension([x509.ExtendedKeyUsage[CertExtendedKeyUsage.CLIENT_AUTH]], true)
+ ];
+
+ leafCert = await x509.X509CertificateGenerator.create({
+ serialNumber,
+ subject,
+ issuer: caCertObj.subject,
+ notBefore: notBeforeDate,
+ notAfter: notAfterDate,
+ signingKey: caPrivateKey,
+ publicKey: csrObj.publicKey,
+ signingAlgorithm: keyAlgorithmToAlgCfg(effectiveKeyAlgorithm),
+ extensions
+ });
+ } else {
+ // Managed mode - server generates key pair (existing behavior)
+ if (!keyAlgorithm) {
+ throw new BadRequestError({ message: "keyAlgorithm is required when not providing a CSR" });
+ }
+ effectiveKeyAlgorithm = keyAlgorithm;
+
+ const alg = keyAlgorithmToAlgCfg(keyAlgorithm);
+ const leafKeys = await crypto.nativeCrypto.subtle.generateKey(alg, true, ["sign", "verify"]);
+
+ const skLeafObj = crypto.nativeCrypto.KeyObject.from(leafKeys.privateKey);
+ privateKeyPem = skLeafObj.export({ format: "pem", type: "pkcs8" }) as string;
+
+ const subject = `OU=${kmipClient.projectId},CN=${clientId}`;
+
+ const extensions: x509.Extension[] = [
+ new x509.BasicConstraintsExtension(false),
+ await x509.AuthorityKeyIdentifierExtension.create(caCertObj, false),
+ await x509.SubjectKeyIdentifierExtension.create(leafKeys.publicKey),
+ new x509.CertificatePolicyExtension(["2.5.29.32.0"]), // anyPolicy
+ new x509.KeyUsagesExtension(
+ // eslint-disable-next-line no-bitwise
+ x509.KeyUsageFlags[CertKeyUsage.DIGITAL_SIGNATURE] |
+ x509.KeyUsageFlags[CertKeyUsage.KEY_ENCIPHERMENT] |
+ x509.KeyUsageFlags[CertKeyUsage.KEY_AGREEMENT],
+ true
+ ),
+ new x509.ExtendedKeyUsageExtension([x509.ExtendedKeyUsage[CertExtendedKeyUsage.CLIENT_AUTH]], true)
+ ];
+
+ leafCert = await x509.X509CertificateGenerator.create({
+ serialNumber,
+ subject,
+ issuer: caCertObj.subject,
+ notBefore: notBeforeDate,
+ notAfter: notAfterDate,
+ signingKey: caPrivateKey,
+ publicKey: leafKeys.publicKey,
+ signingAlgorithm: alg,
+ extensions
+ });
+ }
const rootCaCert = new x509.X509Certificate(orgKmipCAs.rootCaCertificate);
const serverIntermediateCaCert = new x509.X509Certificate(orgKmipCAs.serverIntermediateCaCertificate);
await kmipClientCertificateDAL.create({
kmipClientId: clientId,
- keyAlgorithm,
+ keyAlgorithm: effectiveKeyAlgorithm,
issuedAt: notBeforeDate,
expiration: notAfterDate,
serialNumber
@@ -544,10 +611,10 @@ export const kmipServiceFactory = ({
return {
serialNumber,
- privateKey: skLeafObj.export({ format: "pem", type: "pkcs8" }) as string,
certificate: leafCert.toString("pem"),
certificateChain: constructPemChainFromCerts([serverIntermediateCaCert, rootCaCert]),
- projectId: kmipClient.projectId
+ projectId: kmipClient.projectId,
+ ...(privateKeyPem && { privateKey: privateKeyPem })
};
};
diff --git a/backend/src/ee/services/kmip/kmip-types.ts b/backend/src/ee/services/kmip/kmip-types.ts
index b6ef70a221..a2496e54cc 100644
--- a/backend/src/ee/services/kmip/kmip-types.ts
+++ b/backend/src/ee/services/kmip/kmip-types.ts
@@ -6,8 +6,9 @@ import { KmipPermission } from "./kmip-enum";
export type TCreateKmipClientCertificateDTO = {
clientId: string;
- keyAlgorithm: CertKeyAlgorithm;
+ keyAlgorithm?: CertKeyAlgorithm;
ttl: string;
+ csr?: string;
} & Omit<TProjectPermission, "projectId">;
export type TCreateKmipClientDTO = {
diff --git a/docs/docs.json b/docs/docs.json
index 00cdf252af..32c9e51cb4 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -915,7 +915,13 @@
"documentation/platform/kms/overview",
"documentation/platform/kms/hsm-integration",
"documentation/platform/kms/kubernetes-encryption",
- "documentation/platform/kms/kmip",
+ {
+ "group": "KMIP Integration",
+ "pages": [
+ "documentation/platform/kms/kmip",
+ "documentation/platform/kms/kmip-dell-poweredge"
+ ]
+ },
"documentation/platform/kms/sigstore-cosign"
]
}
diff --git a/docs/documentation/platform/kms/kmip-dell-poweredge.mdx b/docs/documentation/platform/kms/kmip-dell-poweredge.mdx
new file mode 100644
index 0000000000..50e65f2ced
--- /dev/null
+++ b/docs/documentation/platform/kms/kmip-dell-poweredge.mdx
@@ -0,0 +1,64 @@
+---
+title: "Dell PowerEdge SEKM"
+description: "Integrate Infisical KMIP with Dell PowerEdge servers using Secure Enterprise Key Management (SEKM) for Self-Encrypting Drives."
+---
+
+This guide walks you through setting up Secure Enterprise Key Management (SEKM) on Dell PowerEdge servers with iDRAC to encrypt Self-Encrypting Drives (SEDs) using Infisical as your key management server.
+
+## Prerequisites
+
+- Infisical KMIP server deployed and running (see [KMIP Integration](/documentation/platform/kms/kmip))
+- Dell PowerEdge server with iDRAC Enterprise license
+- SEKM license installed on iDRAC
+- Network connectivity between iDRAC and KMIP server on port 5696
+
+## Integration Steps
+
+<Steps>
+ <Step title="Create a KMIP Client in Infisical">
+ In your KMS project, navigate to **KMIP** and create a KMIP client for the iDRAC.
+ </Step>
+
+ <Step title="Configure SEKM on iDRAC">
+ 1. Log into the iDRAC web interface
+ 2. Navigate to **iDRAC Settings > Services**
+ 3. Expand **iDRAC Key Management** and select **SEKM**
+ 4. Enter the KMIP server address and port (default: 5696)
+ 5. Click **Next**
+ </Step>
+
+ <Step title="Generate Certificate Request on iDRAC">
+ When iDRAC prompts you to generate a certificate request, you'll need to enter subject values. You can find the required values in Infisical by clicking **Generate Certificate** on your KMIP client and selecting the **CSR** request method - the modal will display the exact **Client ID** and **Project ID** to use.
+
+ 1. Click **Generate CSR** on iDRAC
+ 2. Enter the certificate information:
+ - **Common Name (CN)**: Enter the **Client ID** shown in Infisical
+ - **Organizational Unit (OU)**: Enter the **Project ID** shown in Infisical
+ - Fill in other fields as needed (Organization, Country, etc.)
+ 3. Click **Generate** and download the certificate request file
+ </Step>
+
+ <Step title="Sign the Certificate in Infisical">
+ 1. In the Infisical modal, paste the certificate request content from iDRAC
+ 2. Set the certificate validity period (e.g., "1y" for one year)
+ 3. Click **Sign Certificate**
+ 4. Download the signed certificate and certificate chain
+ </Step>
+
+ <Step title="Upload Certificate to iDRAC">
+ 1. In iDRAC, upload the signed client certificate
+ 2. Upload the certificate chain as the KMS CA certificate
+ 3. Click **Test Network Connection** to verify connectivity
+ 4. Complete the SEKM configuration
+ </Step>
+
+ <Step title="Enable Encryption on Storage Controller">
+ Once SEKM is configured, you can enable encryption on your storage controller (PERC, HBA, or NVMe) through iDRAC.
+ </Step>
+</Steps>
+
+## Troubleshooting
+
+- **Certificate validation fails**: Make sure you used the correct Client ID and Project ID when generating the certificate request on iDRAC.
+- **Connection timeout**: Verify network connectivity and that firewall rules allow traffic on port 5696.
+- **Authentication errors**: Ensure you uploaded both the signed certificate and the certificate chain to iDRAC.
diff --git a/docs/documentation/platform/kms/kmip.mdx b/docs/documentation/platform/kms/kmip.mdx
index a6c76a1e52..ce5f5e1b9e 100644
--- a/docs/documentation/platform/kms/kmip.mdx
+++ b/docs/documentation/platform/kms/kmip.mdx
@@ -1,5 +1,5 @@
---
-title: "KMIP Integration"
+title: "Overview"
description: "Learn more about integrating with Infisical KMS using KMIP (Key Management Interoperability Protocol)."
---
@@ -147,19 +147,11 @@ Follow these steps in order to set up KMIP integration with Infisical:
<Step title="Generate Client Certificate">
Each KMIP client needs its own certificate for mTLS authentication.
- Click **Generate Certificate** for your newly created client.
-
- ![KMIP generate client cert](/images/platform/kms/kmip/kmip-client-generate-cert.png)
-
- Provide the desired TTL (time-to-live) and key algorithm, then click **Generate Client Certificate**.
-
- ![KMIP client cert config](/images/platform/kms/kmip/kmip-client-cert-config-modal.png)
-
- Download the generated client certificate, certificate chain, and private key.
-
- ![KMIP client cert modal](/images/platform/kms/kmip/kmip-client-certificate-modal.png)
+ Click **Generate Certificate** for your newly created client. Select the request method:
+ - **Managed**: Infisical generates the key pair and certificate for you. Provide the TTL and key algorithm.
+ - **CSR**: Provide your own Certificate Signing Request if your device generates keys internally (e.g., Dell iDRAC). See the [Dell PowerEdge SEKM](/documentation/platform/kms/kmip-dell-poweredge) guide for details.
- Configure your KMIP-compatible applications or tools to use these credentials when connecting to the KMIP server. The client will now authenticate via mTLS and perform authorized key management operations through the KMIP server, which proxies requests to Infisical KMS.
+ Download the generated certificate and certificate chain (and private key if using Managed mode). Configure your KMIP-compatible applications or tools to use these credentials when connecting to the KMIP server.
</Step>
</Steps>
diff --git a/docs/images/platform/kms/kmip/kmip-client-cert-config-modal.png b/docs/images/platform/kms/kmip/kmip-client-cert-config-modal.png
deleted file mode 100644
index 45eb8c830b..0000000000
Binary files a/docs/images/platform/kms/kmip/kmip-client-cert-config-modal.png and /dev/null differ
diff --git a/docs/images/platform/kms/kmip/kmip-client-certificate-modal.png b/docs/images/platform/kms/kmip/kmip-client-certificate-modal.png
deleted file mode 100644
index d6f9fc2ad8..0000000000
Binary files a/docs/images/platform/kms/kmip/kmip-client-certificate-modal.png and /dev/null differ
diff --git a/docs/images/platform/kms/kmip/kmip-client-generate-cert.png b/docs/images/platform/kms/kmip/kmip-client-generate-cert.png
deleted file mode 100644
index 40b49f5707..0000000000
Binary files a/docs/images/platform/kms/kmip/kmip-client-generate-cert.png and /dev/null differ
diff --git a/frontend/src/hooks/api/kmip/types.ts b/frontend/src/hooks/api/kmip/types.ts
index 1bdcda85a6..9cee7942b4 100644
--- a/frontend/src/hooks/api/kmip/types.ts
+++ b/frontend/src/hooks/api/kmip/types.ts
@@ -37,16 +37,17 @@ export type TProjectKmipClientList = {
};
export type TGenerateKmipClientCertificate = {
- keyAlgorithm: CertKeyAlgorithm;
+ keyAlgorithm?: CertKeyAlgorithm;
ttl: string;
clientId: string;
+ csr?: string;
};
export type KmipClientCertificate = {
serialNumber: string;
certificate: string;
certificateChain: string;
- privateKey: string;
+ privateKey?: string;
};
export type TDeleteKmipClient = KeyRef & ProjectRef;
diff --git a/frontend/src/pages/kms/KmipPage/components/CreateKmipClientCertificateModal.tsx b/frontend/src/pages/kms/KmipPage/components/CreateKmipClientCertificateModal.tsx
index 6821773662..1a01238334 100644
--- a/frontend/src/pages/kms/KmipPage/components/CreateKmipClientCertificateModal.tsx
+++ b/frontend/src/pages/kms/KmipPage/components/CreateKmipClientCertificateModal.tsx
@@ -1,4 +1,6 @@
import { Controller, useForm } from "react-hook-form";
+import { faCopy, faInfoCircle, faQuestionCircle } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
@@ -6,23 +8,43 @@ import { createNotification } from "@app/components/notifications";
import {
Button,
FormControl,
+ FormLabel,
+ IconButton,
Input,
Modal,
ModalClose,
ModalContent,
Select,
- SelectItem
+ SelectItem,
+ TextArea,
+ Tooltip
} from "@app/components/v2";
import { certKeyAlgorithms, isPqcAlgorithm } from "@app/hooks/api/certificates/constants";
import { CertKeyAlgorithm } from "@app/hooks/api/certificates/enums";
import { useGenerateKmipClientCertificate } from "@app/hooks/api/kmip";
import { KmipClientCertificate, TKmipClient } from "@app/hooks/api/kmip/types";
-const formSchema = z.object({
- keyAlgorithm: z.nativeEnum(CertKeyAlgorithm),
- ttl: z.string()
+enum RequestMethod {
+ MANAGED = "managed",
+ CSR = "csr"
+}
+
+const baseSchema = z.object({
+ ttl: z.string().min(1, "TTL is required")
+});
+
+const csrSchema = baseSchema.extend({
+ requestMethod: z.literal(RequestMethod.CSR),
+ csr: z.string().min(1, "CSR is required")
+});
+
+const managedSchema = baseSchema.extend({
+ requestMethod: z.literal(RequestMethod.MANAGED),
+ keyAlgorithm: z.nativeEnum(CertKeyAlgorithm)
});
+const formSchema = z.discriminatedUnion("requestMethod", [csrSchema, managedSchema]);
+
export type FormData = z.infer<typeof formSchema>;
type Props = {
@@ -46,69 +68,223 @@ const KmipClientCertificateForm = ({
const {
control,
handleSubmit,
+ watch,
formState: { isSubmitting }
} = useForm<FormData>({
- resolver: zodResolver(formSchema)
+ resolver: zodResolver(formSchema),
+ defaultValues: {
+ requestMethod: RequestMethod.MANAGED,
+ keyAlgorithm: CertKeyAlgorithm.RSA_2048,
+ ttl: ""
+ }
});
+ const requestMethod = watch("requestMethod");
+
const handleKmipClientSubmit = async (payload: FormData) => {
if (!kmipClient) {
return;
}
- const certificate = await createKmipClientCertificate({
- ...payload,
- clientId: kmipClient?.id
- });
+ try {
+ const certificate = await createKmipClientCertificate({
+ ttl: payload.ttl,
+ clientId: kmipClient.id,
+ ...(payload.requestMethod === RequestMethod.CSR
+ ? { csr: payload.csr }
+ : { keyAlgorithm: payload.keyAlgorithm })
+ });
+
+ createNotification({
+ text: `Successfully ${payload.requestMethod === RequestMethod.CSR ? "signed" : "generated"} KMIP client certificate`,
+ type: "success"
+ });
+ displayNewClientCertificate(certificate);
+ onComplete();
+ } catch (error) {
+ createNotification({
+ text: `Failed to create certificate: ${(error as Error)?.message || "Unknown error"}`,
+ type: "error"
+ });
+ }
+ };
+
+ const handleCopyToClipboard = (text: string, label: string) => {
+ navigator.clipboard.writeText(text);
createNotification({
- text: "Successfully created KMIP client certificate",
+ text: `${label} copied to clipboard`,
type: "success"
});
-
- displayNewClientCertificate(certificate);
- onComplete();
};
return (
<form onSubmit={handleSubmit(handleKmipClientSubmit)}>
<Controller
control={control}
- name="ttl"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="TTL" isError={Boolean(error)} errorText={error?.message} isRequired>
- <Input {...field} placeholder="2 days, 1d, 2h, 1y, ..." />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- name="keyAlgorithm"
- defaultValue={CertKeyAlgorithm.RSA_2048}
- render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ name="requestMethod"
+ render={({ field: { onChange, value } }) => (
<FormControl
- label="Key Algorithm"
- errorText={error?.message}
- isError={Boolean(error)}
- helperText="This defines the key algorithm to use for signing the client certificate."
+ label={
+ <FormLabel
+ label="Request Method"
+ icon={
+ <Tooltip
+ content={
+ <div className="space-y-2">
+ <p>
+ <strong>Managed:</strong> Infisical generates and manages the private key
+ for you.
+ </p>
+ <p>
+ <strong>CSR:</strong> Provide your own Certificate Signing Request. Use
+ this when your device (e.g., Dell iDRAC) generates its own private key.
+ </p>
+ </div>
+ }
+ >
+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" />
+ </Tooltip>
+ }
+ />
+ }
>
<Select
- defaultValue={field.value}
- {...field}
- onValueChange={(e) => onChange(e)}
+ value={value}
+ onValueChange={(val) => onChange(val as RequestMethod)}
className="w-full"
>
- {certKeyAlgorithms
- .filter(({ value }) => !isPqcAlgorithm(value))
- .map(({ label, value }) => (
- <SelectItem value={String(value || "")} key={label}>
- {label}
- </SelectItem>
- ))}
+ <SelectItem value={RequestMethod.MANAGED}>Managed</SelectItem>
+ <SelectItem value={RequestMethod.CSR}>Certificate Signing Request (CSR)</SelectItem>
</Select>
</FormControl>
)}
/>
+
+ <Controller
+ control={control}
+ name="ttl"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="TTL" isError={Boolean(error)} errorText={error?.message} isRequired>
+ <Input {...field} placeholder="2 days, 1d, 2h, 1y, ..." />
+ </FormControl>
+ )}
+ />
+
+ {requestMethod === RequestMethod.MANAGED && (
+ <Controller
+ control={control}
+ name="keyAlgorithm"
+ defaultValue={CertKeyAlgorithm.RSA_2048}
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl
+ label="Key Algorithm"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ helperText="This defines the key algorithm to use for signing the client certificate."
+ >
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="w-full"
+ >
+ {certKeyAlgorithms
+ .filter(({ value }) => !isPqcAlgorithm(value))
+ .map(({ label, value }) => (
+ <SelectItem value={String(value || "")} key={label}>
+ {label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ )}
+
+ {requestMethod === RequestMethod.CSR && (
+ <>
+ <Controller
+ control={control}
+ name="csr"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Certificate Signing Request (CSR)"
+ isRequired
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <TextArea
+ {...field}
+ spellCheck={false}
+ placeholder={
+ "-----BEGIN CERTIFICATE REQUEST-----\n" +
+ "MIIByDCCAU4CAQAwfjELMAkGA1UEBhMCVVMx...\n" +
+ "-----END CERTIFICATE REQUEST-----"
+ }
+ rows={8}
+ className="w-full font-mono text-xs"
+ />
+ </FormControl>
+ )}
+ />
+
+ {kmipClient && (
+ <div className="mt-4 rounded-md border border-mineshaft-600 bg-mineshaft-700 p-4">
+ <div className="mb-3 flex items-center text-sm font-medium text-mineshaft-200">
+ <FontAwesomeIcon icon={faInfoCircle} className="mr-2" />
+ Certificate Subject Values
+ </div>
+ <p className="mb-3 text-xs text-mineshaft-300">
+ The signed certificate will use these fixed values for CN and OU. If your device
+ requires you to specify subject values when generating the CSR, use the values
+ below.
+ </p>
+ <div className="space-y-2">
+ <div className="flex items-center justify-between rounded bg-mineshaft-600 px-3 py-2">
+ <div>
+ <div className="text-xs text-mineshaft-400">
+ CN (Common Name) = KMIP Client ID
+ </div>
+ <div className="font-mono text-sm text-mineshaft-100">{kmipClient.id}</div>
+ </div>
+ <IconButton
+ ariaLabel="Copy Client ID"
+ variant="plain"
+ size="sm"
+ onClick={() => handleCopyToClipboard(kmipClient.id, "Client ID")}
+ >
+ <FontAwesomeIcon icon={faCopy} />
+ </IconButton>
+ </div>
+ <div className="flex items-center justify-between rounded bg-mineshaft-600 px-3 py-2">
+ <div>
+ <div className="text-xs text-mineshaft-400">
+ OU (Organizational Unit) = Project ID
+ </div>
+ <div className="font-mono text-sm text-mineshaft-100">
+ {kmipClient.projectId}
+ </div>
+ </div>
+ <IconButton
+ ariaLabel="Copy Project ID"
+ variant="plain"
+ size="sm"
+ onClick={() => handleCopyToClipboard(kmipClient.projectId, "Project ID")}
+ >
+ <FontAwesomeIcon icon={faCopy} />
+ </IconButton>
+ </div>
+ </div>
+ <p className="mt-3 text-xs text-mineshaft-400">
+ Note: Any O (Organization), L (Locality), ST (State), or C (Country) values in your
+ CSR will be included in the certificate.
+ </p>
+ </div>
+ )}
+ </>
+ )}
+
<div className="mt-8 flex items-center">
<Button
className="mr-4"
@@ -117,7 +293,7 @@ const KmipClientCertificateForm = ({
isLoading={isSubmitting}
isDisabled={isSubmitting}
>
- Generate Client Certificate
+ {requestMethod === RequestMethod.CSR ? "Sign Certificate" : "Generate Certificate"}
</Button>
<ModalClose asChild>
<Button colorSchema="secondary" variant="plain">