Skip to content

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

feat(kmip): configure server certificate in the UI and add /connect endpoint

bernie-g9ba870c0d5c0
diff --git a/backend/src/db/migrations/20260605120000_kmip-server-cert-config.ts b/backend/src/db/migrations/20260605120000_kmip-server-cert-config.ts
new file mode 100644
index 0000000000..caa89d10aa
--- /dev/null
+++ b/backend/src/db/migrations/20260605120000_kmip-server-cert-config.ts
@@ -0,0 +1,31 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+// Enrollment-based KMIP servers store their certificate config on the resource itself (set in the
+// UI at creation) instead of having the daemon pass it on every launch. The /connect endpoint
+// reads these; the legacy machine-identity /server-registration path still takes them in the body.
+const COLUMNS = ["hostnamesOrIps", "ttl", "commonName", "keyAlgorithm"] as const;
+
+export async function up(knex: Knex): Promise<void> {
+ if (await knex.schema.hasTable(TableName.KmipServer)) {
+ await knex.schema.alterTable(TableName.KmipServer, (t) => {
+ COLUMNS.forEach((col) => t.string(col));
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ if (await knex.schema.hasTable(TableName.KmipServer)) {
+ const cols: string[] = [];
+ for (const col of COLUMNS) {
+ // eslint-disable-next-line no-await-in-loop
+ if (await knex.schema.hasColumn(TableName.KmipServer, col)) cols.push(col);
+ }
+ if (cols.length) {
+ await knex.schema.alterTable(TableName.KmipServer, (t) => {
+ t.dropColumns(...cols);
+ });
+ }
+ }
+}
diff --git a/backend/src/db/schemas/kmip-servers.ts b/backend/src/db/schemas/kmip-servers.ts
index 8c020ad771..2d13bace14 100644
--- a/backend/src/db/schemas/kmip-servers.ts
+++ b/backend/src/db/schemas/kmip-servers.ts
@@ -14,7 +14,11 @@ export const KmipServersSchema = z.object({
orgId: z.string().uuid(),
name: z.string(),
heartbeat: z.date().nullable().optional(),
- tokenVersion: z.number().default(0)
+ tokenVersion: z.number().default(0),
+ hostnamesOrIps: z.string().nullable().optional(),
+ ttl: z.string().nullable().optional(),
+ commonName: z.string().nullable().optional(),
+ keyAlgorithm: z.string().nullable().optional()
});
export type TKmipServers = z.infer<typeof KmipServersSchema>;
diff --git a/backend/src/ee/routes/v1/kmip-router.ts b/backend/src/ee/routes/v1/kmip-router.ts
index 6dc44aeb70..da4e61f912 100644
--- a/backend/src/ee/routes/v1/kmip-router.ts
+++ b/backend/src/ee/routes/v1/kmip-router.ts
@@ -352,7 +352,9 @@ export const registerKmipRouter = async (server: FastifyZodProvider) => {
})
}
},
- onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.KMIP_SERVER_ACCESS_TOKEN]),
+ // Legacy machine-identity servers only. Enrollment-based servers use POST /kmip/servers/connect,
+ // which reads the cert config from the stored server entity instead of the request body.
+ onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
const { hostnamesOrIps } = req.body;
diff --git a/backend/src/ee/routes/v1/kmip-server-router.ts b/backend/src/ee/routes/v1/kmip-server-router.ts
index 29b2eda554..e1bb8a2741 100644
--- a/backend/src/ee/routes/v1/kmip-server-router.ts
+++ b/backend/src/ee/routes/v1/kmip-server-router.ts
@@ -4,17 +4,24 @@ import { KmipServersSchema } from "@app/db/schemas";
import { EventType, UserAgentType } from "@app/ee/services/audit-log/audit-log-types";
import { validateAccountIds, validatePrincipalArns } from "@app/ee/services/resource-auth-method/aws-auth-validators";
import { ResourceAuthMethodType } from "@app/ee/services/resource-auth-method/resource-auth-method-fns";
-import { UnauthorizedError } from "@app/lib/errors";
+import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
+import { ms } from "@app/lib/ms";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { slugSchema } from "@app/server/lib/schemas";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { ActorType, AuthMode } from "@app/services/auth/auth-type";
+import { CertKeyAlgorithm } from "@app/services/certificate/certificate-types";
+import { validateAltNamesField } from "@app/services/certificate-authority/certificate-authority-validators";
const loginRateLimit = { windowMs: 60 * 1000, max: 10 };
const SanitizedKmipServerSchema = KmipServersSchema.pick({
id: true,
name: true,
+ hostnamesOrIps: true,
+ ttl: true,
+ commonName: true,
+ keyAlgorithm: true,
createdAt: true,
updatedAt: true,
heartbeat: true
@@ -22,6 +29,10 @@ const SanitizedKmipServerSchema = KmipServersSchema.pick({
canRevoke: z.boolean()
});
+// Cert config lives on the server entity (set in the UI). The daemon's /connect call reads it,
+// rather than passing it on every launch. ttl/keyAlgorithm get sensible defaults.
+const ttlField = z.string().refine((val) => ms(val) > 0, "TTL must be a positive number");
+
const AwsAuthMethodConfigSchema = z.object({
id: z.string().uuid(),
stsEndpoint: z.string(),
@@ -76,6 +87,10 @@ export const registerKmipServerRouter = async (server: FastifyZodProvider) => {
description: "Create a new KMIP server with an initial auth method.",
body: z.object({
name: slugSchema({ min: 1, max: 32, field: "name" }),
+ hostnamesOrIps: validateAltNamesField,
+ ttl: ttlField.optional().default("1y"),
+ commonName: z.string().trim().min(1).optional(),
+ keyAlgorithm: z.nativeEnum(CertKeyAlgorithm).optional().default(CertKeyAlgorithm.RSA_2048),
authMethod: SettableAuthMethodInputSchema
}),
response: {
@@ -84,7 +99,7 @@ export const registerKmipServerRouter = async (server: FastifyZodProvider) => {
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const { authMethod: authMethodInput, name } = req.body;
+ const { authMethod: authMethodInput, name, hostnamesOrIps, ttl, commonName, keyAlgorithm } = req.body;
const authMethodArg =
authMethodInput.method === ResourceAuthMethodType.Aws
? {
@@ -99,6 +114,10 @@ export const registerKmipServerRouter = async (server: FastifyZodProvider) => {
const kmipServer = await server.services.kmipServer.createKmipServer({
name,
+ hostnamesOrIps,
+ ttl,
+ commonName,
+ keyAlgorithm,
authMethod: authMethodArg,
actor: {
type: req.permission.type,
@@ -179,6 +198,10 @@ export const registerKmipServerRouter = async (server: FastifyZodProvider) => {
schema: {
params: z.object({ kmipServerId: z.string().uuid() }),
body: z.object({
+ hostnamesOrIps: validateAltNamesField.optional(),
+ ttl: ttlField.optional(),
+ commonName: z.string().trim().min(1).optional(),
+ keyAlgorithm: z.nativeEnum(CertKeyAlgorithm).optional(),
authMethod: SettableAuthMethodInputSchema.optional()
}),
response: {
@@ -187,10 +210,23 @@ export const registerKmipServerRouter = async (server: FastifyZodProvider) => {
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const kmipServer = await server.services.kmipServer.getOrgKmipServer({
- kmipServerId: req.params.kmipServerId,
- orgId: req.permission.orgId
- });
+ const { hostnamesOrIps, ttl, commonName, keyAlgorithm } = req.body;
+ const hasFieldUpdate =
+ hostnamesOrIps !== undefined || ttl !== undefined || commonName !== undefined || keyAlgorithm !== undefined;
+
+ const kmipServer = hasFieldUpdate
+ ? await server.services.kmipServer.updateKmipServer({
+ kmipServerId: req.params.kmipServerId,
+ hostnamesOrIps,
+ ttl,
+ commonName,
+ keyAlgorithm,
+ actor: req.permission
+ })
+ : await server.services.kmipServer.getOrgKmipServer({
+ kmipServerId: req.params.kmipServerId,
+ orgId: req.permission.orgId
+ });
if (req.body.authMethod) {
const authMethodInput = req.body.authMethod;
@@ -459,4 +495,74 @@ export const registerKmipServerRouter = async (server: FastifyZodProvider) => {
};
}
});
+
+ // ─── POST /connect ────────────────────────────────────────────────────────
+ // Enrollment-based servers fetch their TLS certificate here. The cert config (SANs, TTL,
+ // common name, key algorithm) is read from the stored server entity — nothing is passed in
+ // the request body. The legacy machine-identity path uses /kmip/server-registration instead.
+ server.route({
+ method: "POST",
+ url: "/connect",
+ config: { rateLimit: writeLimit },
+ schema: {
+ response: {
+ 200: z.object({
+ clientCertificateChain: z.string(),
+ certificateChain: z.string(),
+ certificate: z.string(),
+ privateKey: z.string()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.KMIP_SERVER_ACCESS_TOKEN]),
+ handler: async (req) => {
+ const kmipServer = await server.services.kmipServer.getOrgKmipServer({
+ kmipServerId: req.permission.id,
+ orgId: req.permission.orgId
+ });
+
+ if (!kmipServer.hostnamesOrIps) {
+ throw new BadRequestError({
+ message: "KMIP server has no hostnames or IPs configured. Set them before connecting."
+ });
+ }
+
+ const resolvedCommonName = kmipServer.commonName ?? kmipServer.name;
+ const resolvedTtl = kmipServer.ttl ?? "1y";
+ const resolvedKeyAlgorithm = (kmipServer.keyAlgorithm as CertKeyAlgorithm) ?? undefined;
+
+ const configs = await server.services.kmip.registerServer({
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId,
+ hostnamesOrIps: kmipServer.hostnamesOrIps,
+ ttl: resolvedTtl,
+ commonName: resolvedCommonName,
+ keyAlgorithm: resolvedKeyAlgorithm
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: req.permission.orgId,
+ event: {
+ type: EventType.REGISTER_KMIP_SERVER,
+ metadata: {
+ serverCertificateSerialNumber: configs.serverCertificateSerialNumber,
+ hostnamesOrIps: kmipServer.hostnamesOrIps,
+ commonName: resolvedCommonName,
+ keyAlgorithm: resolvedKeyAlgorithm ?? CertKeyAlgorithm.RSA_2048,
+ ttl: resolvedTtl
+ }
+ }
+ });
+
+ return {
+ clientCertificateChain: configs.clientCertificateChain,
+ certificateChain: configs.certificateChain,
+ certificate: configs.certificate,
+ privateKey: configs.privateKey
+ };
+ }
+ });
};
diff --git a/backend/src/ee/services/kmip-server/kmip-server-service.ts b/backend/src/ee/services/kmip-server/kmip-server-service.ts
index 074f2e4a9f..43a5aa410c 100644
--- a/backend/src/ee/services/kmip-server/kmip-server-service.ts
+++ b/backend/src/ee/services/kmip-server/kmip-server-service.ts
@@ -42,10 +42,18 @@ export const kmipServerServiceFactory = ({
const createKmipServer = async ({
name,
+ hostnamesOrIps,
+ ttl,
+ commonName,
+ keyAlgorithm,
authMethod,
actor
}: {
name: string;
+ hostnamesOrIps: string;
+ ttl?: string;
+ commonName?: string;
+ keyAlgorithm?: string;
authMethod:
| { method: "aws"; config: { stsEndpoint: string; allowedPrincipalArns: string; allowedAccountIds: string } }
| { method: "token" };
@@ -55,7 +63,10 @@ export const kmipServerServiceFactory = ({
try {
return await kmipServerDAL.transaction(async (tx) => {
- const created = await kmipServerDAL.create({ name, orgId: actor.orgId }, tx);
+ const created = await kmipServerDAL.create(
+ { name, orgId: actor.orgId, hostnamesOrIps, ttl, commonName, keyAlgorithm },
+ tx
+ );
await resourceAuthMethodService.initAtCreate({ resource: { type: "kmip", id: created.id }, authMethod }, tx);
return created;
});
@@ -67,6 +78,28 @@ export const kmipServerServiceFactory = ({
}
};
+ const updateKmipServer = async ({
+ kmipServerId,
+ actor,
+ ...fields
+ }: {
+ kmipServerId: string;
+ hostnamesOrIps?: string;
+ ttl?: string;
+ commonName?: string;
+ keyAlgorithm?: string;
+ actor: TActor;
+ }) => {
+ await $checkPermission(actor, OrgPermissionKmipServerActions.EditKmipServers);
+
+ const kmipServer = await kmipServerDAL.findOne({ id: kmipServerId, orgId: actor.orgId });
+ if (!kmipServer) {
+ throw new NotFoundError({ message: `KMIP server ${kmipServerId} not found` });
+ }
+
+ return kmipServerDAL.updateById(kmipServerId, fields);
+ };
+
const getOrgKmipServer = async ({ kmipServerId, orgId }: { kmipServerId: string; orgId: string }) => {
const kmipServer = await kmipServerDAL.findOne({ id: kmipServerId, orgId });
if (!kmipServer) {
@@ -93,6 +126,7 @@ export const kmipServerServiceFactory = ({
return {
createKmipServer,
+ updateKmipServer,
getOrgKmipServer,
listKmipServers,
deleteKmipServer
diff --git a/docs/cli/commands/kmip.mdx b/docs/cli/commands/kmip.mdx
index 6e5561f531..6dc604a3e6 100644
--- a/docs/cli/commands/kmip.mdx
+++ b/docs/cli/commands/kmip.mdx
@@ -10,7 +10,6 @@ description: "Run the Infisical KMIP server or manage its systemd service"
--enroll-method=token \
--token=<enrollment-token> \
--server-name=<server-name> \
- --hostnames-or-ips=<hostnames-or-ips> \
--domain=<your-infisical-domain>
```
</Tab>
@@ -20,7 +19,6 @@ description: "Run the Infisical KMIP server or manage its systemd service"
--enroll-method=token \
--token=<enrollment-token> \
--server-name=<server-name> \
- --hostnames-or-ips=<hostnames-or-ips> \
--domain=<your-infisical-domain>
sudo systemctl start infisical-kmip
```
@@ -33,6 +31,8 @@ The Infisical KMIP server provides Key Management Interoperability Protocol (KMI
The server is created as an entity in the Infisical UI and then enrolled from the host where you run it, using either a one-time enrollment **token** or **AWS** authentication. The deploy command (including the enrollment token) can be copied from the server's detail page via **Show deploy command**.
+The server's certificate configuration (hostnames/IPs, TTL, common name, and key algorithm) is defined on the server entity in the UI. The CLI fetches it on start, so you do not pass it on the command line. To change the certificate, edit the configuration in the UI and restart the server.
+
For detailed information about KMIP integration, PKI setup, and client configuration, see the [KMIP Integration Guide](/documentation/platform/kms/kmip).
## Subcommands & flags
@@ -46,7 +46,6 @@ infisical kmip start \
--enroll-method=token \
--token=<enrollment-token> \
--server-name=<server-name> \
- --hostnames-or-ips=<hostnames-or-ips> \
--domain=<your-infisical-domain>
```
@@ -132,9 +131,11 @@ Once started, the KMIP server will:
</Accordion>
- <Accordion title="--certificate-ttl">
+ <Accordion title="--certificate-ttl (legacy machine-identity servers only)">
The TTL duration for the server certificate. Default: `1y`.
+ This flag applies only to legacy machine-identity KMIP servers. For servers enrolled via token or AWS, the certificate TTL is configured on the server entity in the UI and read on start, so this flag is ignored.
+
```bash
# Example
infisical kmip start --certificate-ttl="6m" --enroll-method=token --token=<enrollment-token> --server-name=<server-name>
@@ -144,9 +145,11 @@ Once started, the KMIP server will:
</Accordion>
- <Accordion title="--hostnames-or-ips (required)">
+ <Accordion title="--hostnames-or-ips (legacy machine-identity servers only)">
Comma-separated list of hostnames or IP addresses that KMIP clients will use to reach the server. These become the Subject Alternative Names (SANs) of the server's TLS certificate, so they must match how clients connect.
+ This flag applies only to legacy machine-identity KMIP servers. For servers enrolled via token or AWS, the hostnames/IPs are configured on the server entity in the UI and read on start, so this flag is ignored.
+
```bash
# Example
infisical kmip start --hostnames-or-ips="kmip.example.com,10.0.1.50" --enroll-method=token --token=<enrollment-token> --server-name=<server-name>
@@ -167,7 +170,6 @@ sudo infisical kmip systemd install \
--enroll-method=token \
--token=<enrollment-token> \
--server-name=<server-name> \
- --hostnames-or-ips=<hostnames-or-ips> \
--domain=<your-infisical-domain>
sudo systemctl start infisical-kmip
```
@@ -189,7 +191,7 @@ For token enrollment, the single-use token is exchanged for a long-lived access
### Flags
-`infisical kmip systemd install` accepts the same flags as `infisical kmip start` (documented above): `--enroll-method`, `--token`, `--kmip-server-id`, `--server-name`, `--hostnames-or-ips`, `--domain`, `--listen-address`, and `--certificate-ttl`.
+`infisical kmip systemd install` accepts the same flags as `infisical kmip start` (documented above): `--enroll-method`, `--token`, `--kmip-server-id`, `--server-name`, `--domain`, `--listen-address`, and (for legacy machine-identity servers only) `--hostnames-or-ips` and `--certificate-ttl`.
### Service Details
diff --git a/docs/documentation/platform/kms/kmip.mdx b/docs/documentation/platform/kms/kmip.mdx
index 268e6a2ddb..ace186b86a 100644
--- a/docs/documentation/platform/kms/kmip.mdx
+++ b/docs/documentation/platform/kms/kmip.mdx
@@ -62,7 +62,14 @@ A KMIP server is created as an organization-wide entity in Infisical and then en
<Steps>
<Step title="Create the KMIP Server in the UI">
1. In the Infisical dashboard, open **Infisical KMS** and select **KMIP Servers**.
- 2. Click **Create KMIP Server** and enter a **name**.
+ 2. Click **Create KMIP Server** and fill in:
+ - **Name** of the server.
+ - **Hostnames or IPs**: a comma-separated list of the hostnames or IPs that KMIP clients will use to reach this server (for example `kmip.example.com` or `10.0.1.50`). These become the Subject Alternative Names (SANs) of the server's TLS certificate, so they must match how clients connect.
+ - **Common Name** (optional): subject common name for the server certificate. Defaults to the server name.
+ - **Certificate TTL**: validity period of the server certificate (for example `1y`).
+ - **Key Algorithm**: key algorithm used to sign the server certificate.
+
+ This certificate configuration is stored on the server entity. The CLI reads it on start, so you do not pass it on the command line. You can change it later from the server's detail page (edit the **Certificate Configuration** card) and restart the server to apply it.
3. (Optional) Open the new server's detail page and click the edit icon next to **Authentication** to switch the auth method. Two methods are supported:
- **Token** (default): a one-time enrollment token (1h expiry) bootstraps the server.
- **AWS**: the server authenticates by signing an `sts:GetCallerIdentity` request with whatever AWS credentials it can resolve on the host (instance role, env vars, shared profile). Configure the allowed principal ARNs and/or account IDs that match your hosts.
@@ -100,7 +107,6 @@ A KMIP server is created as an organization-wide entity in Infisical and then en
--enroll-method=token \
--token=<enrollment-token> \
--server-name=<server-name> \
- --hostnames-or-ips=<hostnames-or-ips> \
--listen-address="0.0.0.0:5696" \
--domain=<your-infisical-domain>
sudo systemctl start infisical-kmip
@@ -112,7 +118,6 @@ A KMIP server is created as an organization-wide entity in Infisical and then en
--enroll-method=token \
--token=<enrollment-token> \
--server-name=<server-name> \
- --hostnames-or-ips=<hostnames-or-ips> \
--listen-address="0.0.0.0:5696" \
--domain=<your-infisical-domain>
```
@@ -129,7 +134,6 @@ A KMIP server is created as an organization-wide entity in Infisical and then en
--enroll-method=aws \
--kmip-server-id=<kmip-server-id> \
--server-name=<server-name> \
- --hostnames-or-ips=<hostnames-or-ips> \
--listen-address="0.0.0.0:5696" \
--domain=<your-infisical-domain>
sudo systemctl start infisical-kmip
@@ -141,7 +145,6 @@ A KMIP server is created as an organization-wide entity in Infisical and then en
--enroll-method=aws \
--kmip-server-id=<kmip-server-id> \
--server-name=<server-name> \
- --hostnames-or-ips=<hostnames-or-ips> \
--listen-address="0.0.0.0:5696" \
--domain=<your-infisical-domain>
```
@@ -155,7 +158,7 @@ A KMIP server is created as an organization-wide entity in Infisical and then en
</Warning>
<Note>
- Replace `<hostnames-or-ips>` with a comma-separated list of the hostnames or IPs that KMIP clients will use to reach this server (for example `kmip.example.com` or `10.0.1.50`). These become the Subject Alternative Names (SANs) of the server's TLS certificate, so they must match how clients connect.
+ The server's certificate configuration (hostnames/IPs, TTL, common name, key algorithm) is read from the server entity you configured in the UI, so the deploy command does not include it. To change the certificate, edit the **Certificate Configuration** card on the server's detail page and restart the server.
</Note>
<Note>
@@ -189,6 +192,7 @@ A KMIP server is created as an organization-wide entity in Infisical and then en
From the KMIP server's detail page (under **Infisical KMS > KMIP Servers**):
- **Show deploy command** — Generates a fresh enrollment token (token method) or re-displays the AWS start command. For token-method servers this does not disconnect a running server; the next enrollment with the new token supersedes the old one.
+- **Edit certificate configuration**: Update the hostnames/IPs, common name, TTL, or key algorithm used for the server's TLS certificate. Restart the server after saving for the new certificate to take effect.
- **Edit authentication** — Switch between Token and AWS, or update the AWS allowlists.
- **Options → Revoke Access** — Invalidates the server's outstanding access tokens and enrollment tokens. The server must re-enroll to reconnect.
- **Options → Delete** — Permanently removes the KMIP server entity.
@@ -249,7 +253,7 @@ While exact configuration steps vary by application, you'll generally need to pr
### General Configuration Steps
<Steps>
<Step title="Identify Your KMIP Server Endpoint">
- Determine the address where your KMIP server is accessible. This should match one of the hostnames or IPs you passed via `--hostnames-or-ips` when deploying the server.
+ Determine the address where your KMIP server is accessible. This should match one of the hostnames or IPs configured on the server entity in the UI.
**Example endpoints:**
- `my-kmip-server.com:5696`
diff --git a/frontend/src/hooks/api/kmipServers/mutations.tsx b/frontend/src/hooks/api/kmipServers/mutations.tsx
index 552523e5cc..9fb29392b1 100644
--- a/frontend/src/hooks/api/kmipServers/mutations.tsx
+++ b/frontend/src/hooks/api/kmipServers/mutations.tsx
@@ -42,9 +42,20 @@ export const useCreateKmipServer = () => {
export const useUpdateKmipServer = () => {
const queryClient = useQueryClient();
return useMutation({
- mutationFn: async ({ kmipServerId, authMethod }: TUpdateKmipServerDTO) => {
+ mutationFn: async ({
+ kmipServerId,
+ authMethod,
+ hostnamesOrIps,
+ ttl,
+ commonName,
+ keyAlgorithm
+ }: TUpdateKmipServerDTO) => {
const body: Record<string, unknown> = {};
if (authMethod !== undefined) body.authMethod = authMethod;
+ if (hostnamesOrIps !== undefined) body.hostnamesOrIps = hostnamesOrIps;
+ if (ttl !== undefined) body.ttl = ttl;
+ if (commonName !== undefined) body.commonName = commonName;
+ if (keyAlgorithm !== undefined) body.keyAlgorithm = keyAlgorithm;
const { data } = await apiRequest.patch<TKmipServerWithAuthMethod>(
`/api/v1/kmip/servers/${kmipServerId}`,
diff --git a/frontend/src/hooks/api/kmipServers/types.ts b/frontend/src/hooks/api/kmipServers/types.ts
index b37c08ecce..5866f495ab 100644
--- a/frontend/src/hooks/api/kmipServers/types.ts
+++ b/frontend/src/hooks/api/kmipServers/types.ts
@@ -1,3 +1,5 @@
+import { CertKeyAlgorithm } from "@app/hooks/api/certificates/enums";
+
export type TKmipServerAuthMethodView =
| {
method: "aws";
@@ -26,6 +28,10 @@ export type TKmipServer = {
orgId: string;
name: string;
heartbeat: string | null;
+ hostnamesOrIps: string | null;
+ ttl: string | null;
+ commonName: string | null;
+ keyAlgorithm: string | null;
};
export type TKmipServerWithAuthMethod = TKmipServer & {
@@ -39,6 +45,10 @@ export type TDeleteKmipServerDTO = {
export type TCreateKmipServerDTO = {
name: string;
+ hostnamesOrIps: string;
+ ttl?: string;
+ commonName?: string;
+ keyAlgorithm?: CertKeyAlgorithm;
authMethod:
| {
method: "aws";
@@ -51,6 +61,10 @@ export type TCreateKmipServerDTO = {
export type TUpdateKmipServerDTO = {
kmipServerId: string;
+ hostnamesOrIps?: string;
+ ttl?: string;
+ commonName?: string;
+ keyAlgorithm?: CertKeyAlgorithm;
authMethod?:
| {
method: "aws";
diff --git a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerCertConfig/KmipServerCertConfigModal.tsx b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerCertConfig/KmipServerCertConfigModal.tsx
new file mode 100644
index 0000000000..945e079ee2
--- /dev/null
+++ b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerCertConfig/KmipServerCertConfigModal.tsx
@@ -0,0 +1,192 @@
+import { useEffect } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldContent,
+ FieldError,
+ FieldLabel,
+ FilterableSelect,
+ Input
+} from "@app/components/v3";
+import { useOrganization } from "@app/context";
+import { certKeyAlgorithms, isPqcAlgorithm } from "@app/hooks/api/certificates/constants";
+import { CertKeyAlgorithm } from "@app/hooks/api/certificates/enums";
+import { useUpdateKmipServer } from "@app/hooks/api/kmipServers";
+import { TKmipServerWithAuthMethod } from "@app/hooks/api/kmipServers/types";
+
+const keyAlgorithmOptions = certKeyAlgorithms.filter(({ value }) => !isPqcAlgorithm(value));
+
+const schema = z.object({
+ hostnamesOrIps: z.string().trim().min(1, "At least one hostname or IP is required"),
+ ttl: z.string().trim().min(1, "TTL is required"),
+ commonName: z.string().trim().optional(),
+ keyAlgorithm: z.nativeEnum(CertKeyAlgorithm)
+});
+
+type FormData = z.infer<typeof schema>;
+
+type Props = {
+ isOpen: boolean;
+ onOpenChange: (isOpen: boolean) => void;
+ kmipServer: TKmipServerWithAuthMethod;
+};
+
+export const KmipServerCertConfigModal = ({ isOpen, onOpenChange, kmipServer }: Props) => {
+ const { mutateAsync: updateKmipServer, isPending } = useUpdateKmipServer();
+ const { isSubOrganization } = useOrganization();
+
+ const defaults: FormData = {
+ hostnamesOrIps: kmipServer.hostnamesOrIps ?? "",
+ ttl: kmipServer.ttl ?? "1y",
+ commonName: kmipServer.commonName ?? "",
+ keyAlgorithm: (kmipServer.keyAlgorithm as CertKeyAlgorithm) ?? CertKeyAlgorithm.RSA_2048
+ };
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting, isDirty }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: defaults
+ });
+
+ useEffect(() => {
+ if (isOpen) reset(defaults);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [isOpen]);
+
+ const onSubmit = async (form: FormData) => {
+ try {
+ await updateKmipServer({
+ kmipServerId: kmipServer.id,
+ hostnamesOrIps: form.hostnamesOrIps,
+ ttl: form.ttl,
+ commonName: form.commonName?.trim() ? form.commonName.trim() : undefined,
+ keyAlgorithm: form.keyAlgorithm
+ });
+ createNotification({
+ type: "success",
+ text: "Certificate configuration updated. Restart the KMIP server to apply it."
+ });
+ onOpenChange(false);
+ } catch {
+ createNotification({ type: "error", text: "Failed to update certificate configuration" });
+ }
+ };
+
+ return (
+ <Dialog open={isOpen} onOpenChange={onOpenChange}>
+ <DialogContent className="max-w-lg overflow-visible">
+ <DialogHeader>
+ <DialogTitle>Edit Certificate Configuration</DialogTitle>
+ <DialogDescription>
+ Restart the KMIP server after saving for the new certificate to take effect.
+ </DialogDescription>
+ </DialogHeader>
+ <form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
+ <Controller
+ control={control}
+ name="hostnamesOrIps"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel>Hostnames or IPs</FieldLabel>
+ <FieldContent>
+ <Input
+ {...field}
+ isError={Boolean(error)}
+ placeholder="kmip.example.com, 10.0.0.5"
+ />
+ <FieldError errors={[error]} />
+ </FieldContent>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name="commonName"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel>Common Name</FieldLabel>
+ <FieldContent>
+ <Input
+ {...field}
+ isError={Boolean(error)}
+ placeholder="(defaults to server name)"
+ />
+ <FieldError errors={[error]} />
+ </FieldContent>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name="ttl"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel>Certificate TTL</FieldLabel>
+ <FieldContent>
+ <Input {...field} isError={Boolean(error)} placeholder="1y" />
+ <FieldError errors={[error]} />
+ </FieldContent>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name="keyAlgorithm"
+ render={({ field }) => {
+ const selected =
+ keyAlgorithmOptions.find((o) => o.value === field.value) ?? keyAlgorithmOptions[0];
+ return (
+ <Field>
+ <FieldLabel>Key Algorithm</FieldLabel>
+ <FieldContent>
+ <FilterableSelect
+ value={selected}
+ onChange={(opt) => {
+ const next = opt as { value: CertKeyAlgorithm } | null;
+ if (next) field.onChange(next.value);
+ }}
+ options={keyAlgorithmOptions}
+ isSearchable={false}
+ isClearable={false}
+ getOptionLabel={(o) => o.label}
+ getOptionValue={(o) => String(o.value)}
+ />
+ </FieldContent>
+ </Field>
+ );
+ }}
+ />
+
+ <DialogFooter className="gap-2 sm:gap-2">
+ <Button type="button" variant="ghost" onClick={() => onOpenChange(false)}>
+ Cancel
+ </Button>
+ <Button
+ type="submit"
+ variant={isSubOrganization ? "sub-org" : "org"}
+ isPending={isSubmitting || isPending}
+ isDisabled={isSubmitting || isPending || !isDirty}
+ >
+ Update
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+ );
+};
diff --git a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDeploySection/KmipServerDeployCommandDialog.tsx b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDeploySection/KmipServerDeployCommandDialog.tsx
index 34523039c7..4a21c5a190 100644
--- a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDeploySection/KmipServerDeployCommandDialog.tsx
+++ b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDeploySection/KmipServerDeployCommandDialog.tsx
@@ -40,7 +40,7 @@ export const KmipServerDeployCommandDialog = ({
const siteURL = `${protocol}//${hostname}${portSuffix}`;
const cliCommand = useMemo(() => {
- const common = `--hostnames-or-ips=<hostnames-or-ips> --server-name=${kmipServerName} --domain=${siteURL}`;
+ const common = `--server-name=${kmipServerName} --domain=${siteURL}`;
if (authMethod === "aws") {
return `infisical kmip start --enroll-method=aws --kmip-server-id=${kmipServerId} ${common}`;
}
@@ -48,7 +48,7 @@ export const KmipServerDeployCommandDialog = ({
}, [kmipServerName, kmipServerId, enrollmentToken, authMethod, siteURL]);
const systemdInstallCommand = useMemo(() => {
- const common = `--hostnames-or-ips=<hostnames-or-ips> --server-name=${kmipServerName} --domain=${siteURL}`;
+ const common = `--server-name=${kmipServerName} --domain=${siteURL}`;
if (authMethod === "aws") {
return `sudo infisical kmip systemd install --enroll-method=aws --kmip-server-id=${kmipServerId} ${common}`;
}
@@ -63,11 +63,10 @@ export const KmipServerDeployCommandDialog = ({
};
const badgeLabel = authMethod === "aws" ? "AWS Auth" : "Token Auth";
- const baseHelperText =
+ const helperText =
authMethod === "aws"
- ? "The host must have AWS credentials whose principal matches your allowlist."
- : "The enrollment token expires in 1 hour and can only be used once.";
- const helperText = `${baseHelperText} Replace <hostnames-or-ips> with a comma-separated list of the hostnames or IPs that KMIP clients will use to reach this server.`;
+ ? "The host must have AWS credentials whose principal matches your allowlist. The certificate config (hostnames/IPs, TTL, common name, key algorithm) is read from the server's settings."
+ : "The enrollment token expires in 1 hour and can only be used once. The certificate config (hostnames/IPs, TTL, common name, key algorithm) is read from the server's settings.";
return (
<Modal isOpen={isOpen} onOpenChange={onOpenChange}>
diff --git a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDetailsCard/KmipServerDetailsCard.tsx b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDetailsCard/KmipServerDetailsCard.tsx
index 282a9dd53a..ce439eb0d3 100644
--- a/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDetailsCard/KmipServerDetailsCard.tsx
+++ b/frontend/src/pages/organization/KmipServersPage/KmipServerDetailsByIDPage/components/KmipServerDetailsCard/KmipServerDetailsCard.tsx
@@ -33,6 +33,7 @@ import {
} from "@app/hooks/api/kmipServers/types";
import { KmipServerAuthMethodModal } from "../KmipServerAuthMethod/KmipServerAuthMethodModal";
+import { KmipServerCertConfigModal } from "../KmipServerCertConfig/KmipServerCertConfigModal";
const AuthMethodBadge = ({ method }: { method: TKmipServerAuthMethodView["method"] }) => {
if (method === "aws") return <Badge variant="info">AWS Auth</Badge>;
@@ -49,6 +50,7 @@ export const KmipServerDetailsCard = ({
initialState: "Copy ID to clipboard"
});
const [authModalOpen, setAuthModalOpen] = useState(false);
+ const [certConfigModalOpen, setCertConfigModalOpen] = useState(false);
const { currentOrg } = useOrganization();
const orgId = currentOrg?.id || "";
@@ -90,6 +92,52 @@ export const KmipServerDetailsCard = ({
<DetailValue>{format(new Date(kmipServer.createdAt), "PPpp")}</DetailValue>
</Detail>
</DetailGroup>
+ {!isIdentityServer && (
+ <>
+ <Separator className="my-4" />
+ <DetailGroup>
+ <DetailGroupHeader className="flex items-center justify-between">
+ Certificate Configuration
+ <OrgPermissionCan
+ I={OrgKmipServerPermissionActions.EditKmipServers}
+ a={OrgPermissionSubjects.KmipServer}
+ >
+ {(isAllowed) => (
+ <IconButton
+ size="xs"
+ variant="ghost-muted"
+ aria-label="edit certificate configuration"
+ isDisabled={!isAllowed}
+ onClick={() => setCertConfigModalOpen(true)}
+ >
+ <PencilIcon />
+ </IconButton>
+ )}
+ </OrgPermissionCan>
+ </DetailGroupHeader>
+ <Detail>
+ <DetailLabel>Hostnames / IPs</DetailLabel>
+ <DetailValue>
+ {kmipServer.hostnamesOrIps || <span className="text-muted">&mdash;</span>}
+ </DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Common Name</DetailLabel>
+ <DetailValue>
+ {kmipServer.commonName || <span className="text-muted">{kmipServer.name}</span>}
+ </DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Certificate TTL</DetailLabel>
+ <DetailValue>{kmipServer.ttl || "1y"}</DetailValue>
+ </Detail>
+ <Detail>
+ <DetailLabel>Key Algorithm</DetailLabel>
+ <DetailValue>{kmipServer.keyAlgorithm || "RSA_2048"}</DetailValue>
+ </Detail>
+ </DetailGroup>
+ </>
+ )}
<Separator className="my-4" />
<DetailGroup>
<DetailGroupHeader className="flex items-center justify-between">
@@ -175,12 +223,19 @@ export const KmipServerDetailsCard = ({
</Card>
{!isIdentityServer && (
- <KmipServerAuthMethodModal
- isOpen={authModalOpen}
- onOpenChange={setAuthModalOpen}
- kmipServerId={kmipServer.id}
- currentMethod={authMethod}
- />
+ <>
+ <KmipServerAuthMethodModal
+ isOpen={authModalOpen}
+ onOpenChange={setAuthModalOpen}
+ kmipServerId={kmipServer.id}
+ currentMethod={authMethod}
+ />
+ <KmipServerCertConfigModal
+ isOpen={certConfigModalOpen}
+ onOpenChange={setCertConfigModalOpen}
+ kmipServer={kmipServer}
+ />
+ </>
)}
</>
);
diff --git a/frontend/src/pages/organization/KmipServersPage/components/components/KmipServerDeployModal.tsx b/frontend/src/pages/organization/KmipServersPage/components/components/KmipServerDeployModal.tsx
index 2aafb079cd..d5158a6151 100644
--- a/frontend/src/pages/organization/KmipServersPage/components/components/KmipServerDeployModal.tsx
+++ b/frontend/src/pages/organization/KmipServersPage/components/components/KmipServerDeployModal.tsx
@@ -1,37 +1,69 @@
-import { useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate } from "@tanstack/react-router";
+import { z } from "zod";
import { createNotification } from "@app/components/notifications";
-import { Button, FormControl, Input, Modal, ModalClose, ModalContent } from "@app/components/v2";
+import {
+ Button,
+ FormControl,
+ Input,
+ Modal,
+ ModalClose,
+ ModalContent,
+ Select,
+ SelectItem
+} from "@app/components/v2";
import { useOrganization } from "@app/context";
+import { certKeyAlgorithms, isPqcAlgorithm } from "@app/hooks/api/certificates/constants";
+import { CertKeyAlgorithm } from "@app/hooks/api/certificates/enums";
import { useCreateKmipServer } from "@app/hooks/api/kmipServers";
+const schema = z.object({
+ name: z.string().trim().min(1, "Name is required"),
+ hostnamesOrIps: z.string().trim().min(1, "At least one hostname or IP is required"),
+ ttl: z.string().trim().min(1, "TTL is required"),
+ commonName: z.string().trim().optional(),
+ keyAlgorithm: z.nativeEnum(CertKeyAlgorithm)
+});
+
+type FormData = z.infer<typeof schema>;
+
type Props = {
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
};
export const KmipServerDeployModal = ({ isOpen, onOpenChange }: Props) => {
- const [name, setName] = useState("");
- const [formErrors, setFormErrors] = useState<string[]>([]);
-
const { currentOrg } = useOrganization();
const orgId = currentOrg?.id || "";
const navigate = useNavigate();
- const { mutateAsync: createKmipServer, isPending: isCreating } = useCreateKmipServer();
+ const { mutateAsync: createKmipServer } = useCreateKmipServer();
- const handleCreate = async () => {
- const errors: string[] = [];
- if (!name.trim()) errors.push("Name is required");
- if (errors.length) {
- setFormErrors(errors);
- return;
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ name: "",
+ hostnamesOrIps: "",
+ ttl: "1y",
+ commonName: "",
+ keyAlgorithm: CertKeyAlgorithm.RSA_2048
}
- setFormErrors([]);
+ });
+ const onSubmit = async (form: FormData) => {
try {
const kmipServer = await createKmipServer({
- name: name.trim(),
+ name: form.name,
+ hostnamesOrIps: form.hostnamesOrIps,
+ ttl: form.ttl,
+ commonName: form.commonName?.trim() ? form.commonName.trim() : undefined,
+ keyAlgorithm: form.keyAlgorithm,
authMethod: { method: "token" }
});
@@ -49,10 +81,7 @@ export const KmipServerDeployModal = ({ isOpen, onOpenChange }: Props) => {
};
const handleClose = (open: boolean) => {
- if (!open) {
- setName("");
- setFormErrors([]);
- }
+ if (!open) reset();
onOpenChange(open);
};
@@ -64,25 +93,94 @@ export const KmipServerDeployModal = ({ isOpen, onOpenChange }: Props) => {
subTitle="Create a new KMIP server. You can generate an enrollment token and deploy it from the KMIP server detail page."
bodyClassName="overflow-visible"
>
- <div className="flex flex-col gap-4">
- {formErrors.length > 0 && (
- <div className="rounded-md bg-red-500/10 p-3">
- {formErrors.map((e) => (
- <p key={e} className="text-sm text-red-400">
- {e}
- </p>
- ))}
- </div>
- )}
- <FormControl label="Name" isRequired>
- <Input
- value={name}
- onChange={(e) => setName(e.target.value)}
- placeholder="my-kmip-server"
- />
- </FormControl>
- <div className="mt-2 flex items-center gap-2">
- <Button onClick={handleCreate} isLoading={isCreating} isDisabled={isCreating} size="sm">
+ <form onSubmit={handleSubmit(onSubmit)}>
+ <Controller
+ control={control}
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Name"
+ isRequired
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="my-kmip-server" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="hostnamesOrIps"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Hostnames or IPs"
+ isRequired
+ isError={Boolean(error)}
+ errorText={error?.message}
+ helperText="Comma-separated list of the hostnames or IPs that KMIP clients will use to reach this server. These become the server certificate's subject alternative names."
+ >
+ <Input {...field} placeholder="kmip.example.com, 10.0.0.5" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="commonName"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Common Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ helperText="Subject common name for the server certificate. Defaults to the server name."
+ >
+ <Input {...field} placeholder="(defaults to server name)" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="ttl"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Certificate TTL"
+ isRequired
+ isError={Boolean(error)}
+ errorText={error?.message}
+ helperText="Validity period of the server certificate, e.g. 2 days, 1d, 2h, 1y."
+ >
+ <Input {...field} placeholder="1y" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="keyAlgorithm"
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl
+ label="Key Algorithm"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ helperText="Key algorithm used to sign the server 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>
+ )}
+ />
+ <div className="mt-6 flex items-center gap-2">
+ <Button type="submit" isLoading={isSubmitting} isDisabled={isSubmitting} size="sm">
Create KMIP Server
</Button>
<ModalClose asChild>
@@ -91,7 +189,7 @@ export const KmipServerDeployModal = ({ isOpen, onOpenChange }: Props) => {
</Button>
</ModalClose>
</div>
- </div>
+ </form>
</ModalContent>
</Modal>
);