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
Add Venafi TPP external CA integration
Carlos Monastyrski70baae3853b4
diff --git a/backend/package-lock.json b/backend/package-lock.jsonindex 504080a56c..b6db518b3b 100644--- a/backend/package-lock.json+++ b/backend/package-lock.json@@ -6278,9 +6278,6 @@"win32"]},- "node_modules/@infisical/quic/node_modules/@infisical/quic-linux-arm": {- "optional": true- },"node_modules/@ioredis/commands": {"version": "1.5.0","resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.5.0.tgz",diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 956202ade3..9ac587178d 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -2810,6 +2810,14 @@ export const AppConnections = {VENAFI: {apiKey: "The API key used to authenticate with Venafi TLS Protect Cloud.",region: "The region of your Venafi TLS Protect Cloud instance (e.g., 'us', 'eu')."+ },+ VENAFI_TPP: {+ tppUrl: "The HTTPS URL of the Venafi TPP instance (e.g., 'https://tpp.example.com'). Must use HTTPS.",+ clientId:+ "The OAuth client ID registered in the Venafi TPP API Integration. Used for token-based authentication.",+ username:+ "The username used to authenticate with Venafi TPP. Supports formats: 'DOMAIN\\\\username', '[email protected]', or local usernames.",+ password: "The password used to authenticate with Venafi TPP."}}};diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.tsindex 97f5dee7c1..0971a57633 100644--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts@@ -176,6 +176,10 @@ import {TravisCIConnectionListItemSchema} from "@app/services/app-connection/travis-ci";import { SanitizedVenafiConnectionSchema, VenafiConnectionListItemSchema } from "@app/services/app-connection/venafi";+import {+ SanitizedVenafiTppConnectionSchema,+ VenafiTppConnectionListItemSchema+} from "@app/services/app-connection/venafi-tpp";import { SanitizedVercelConnectionSchema, VercelConnectionListItemSchema } from "@app/services/app-connection/vercel";import {SanitizedWindmillConnectionSchema,@@ -240,6 +244,7 @@ const SanitizedAppConnectionSchema = z.union([...SanitizedAnthropicConnectionSchema.options,...SanitizedAzureEntraIdConnectionSchema.options,...SanitizedVenafiConnectionSchema.options,+ ...SanitizedVenafiTppConnectionSchema.options,...SanitizedExternalInfisicalConnectionSchema.options,...SanitizedNetScalerConnectionSchema.options,...SanitizedDopplerConnectionSchema.options,@@ -302,6 +307,7 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [OpenRouterConnectionListItemSchema,AzureEntraIdConnectionListItemSchema,VenafiConnectionListItemSchema,+ VenafiTppConnectionListItemSchema,ExternalInfisicalConnectionListItemSchema,DopplerConnectionListItemSchema,NetScalerConnectionListItemSchema,diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.tsindex 246ae3c275..e6a9250160 100644--- a/backend/src/server/routes/v1/app-connection-routers/index.ts+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts@@ -57,6 +57,7 @@ import { registerTeamCityConnectionRouter } from "./teamcity-connection-router";import { registerTerraformCloudConnectionRouter } from "./terraform-cloud-router";import { registerTravisCIConnectionRouter } from "./travis-ci-connection-router";import { registerVenafiConnectionRouter } from "./venafi-connection-router";+import { registerVenafiTppConnectionRouter } from "./venafi-tpp-connection-router";import { registerVercelConnectionRouter } from "./vercel-connection-router";import { registerWindmillConnectionRouter } from "./windmill-connection-router";import { registerZabbixConnectionRouter } from "./zabbix-connection-router";@@ -118,6 +119,7 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:[AppConnection.CircleCI]: registerCircleCIConnectionRouter,[AppConnection.AzureEntraId]: registerAzureEntraIdConnectionRouter,[AppConnection.Venafi]: registerVenafiConnectionRouter,+ [AppConnection.VenafiTpp]: registerVenafiTppConnectionRouter,[AppConnection.ExternalInfisical]: registerExternalInfisicalConnectionRouter,[AppConnection.Doppler]: registerDopplerConnectionRouter,[AppConnection.NetScaler]: registerNetScalerConnectionRouter,diff --git a/backend/src/server/routes/v1/app-connection-routers/venafi-tpp-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/venafi-tpp-connection-router.tsnew file mode 100644index 0000000000..5789a96333--- /dev/null+++ b/backend/src/server/routes/v1/app-connection-routers/venafi-tpp-connection-router.ts@@ -0,0 +1,18 @@+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import {+ CreateVenafiTppConnectionSchema,+ SanitizedVenafiTppConnectionSchema,+ UpdateVenafiTppConnectionSchema+} from "@app/services/app-connection/venafi-tpp";++import { registerAppConnectionEndpoints } from "./app-connection-endpoints";++export const registerVenafiTppConnectionRouter = async (server: FastifyZodProvider) => {+ registerAppConnectionEndpoints({+ app: AppConnection.VenafiTpp,+ server,+ sanitizedResponseSchema: SanitizedVenafiTppConnectionSchema,+ createSchema: CreateVenafiTppConnectionSchema,+ updateSchema: UpdateVenafiTppConnectionSchema+ });+};diff --git a/backend/src/server/routes/v1/certificate-authority-routers/general-certificate-authority-router.ts b/backend/src/server/routes/v1/certificate-authority-routers/general-certificate-authority-router.tsindex 71c67366b3..d417ce835e 100644--- a/backend/src/server/routes/v1/certificate-authority-routers/general-certificate-authority-router.ts+++ b/backend/src/server/routes/v1/certificate-authority-routers/general-certificate-authority-router.ts@@ -12,6 +12,7 @@ import { AzureAdCsCertificateAuthoritySchema } from "@app/services/certificate-aimport { CaType } from "@app/services/certificate-authority/certificate-authority-enums";import { DigiCertCertificateAuthoritySchema } from "@app/services/certificate-authority/digicert/digicert-certificate-authority-schemas";import { InternalCertificateAuthoritySchema } from "@app/services/certificate-authority/internal/internal-certificate-authority-schemas";+import { VenafiTppCertificateAuthoritySchema } from "@app/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-schemas";const CertificateAuthoritySchema = z.discriminatedUnion("type", [InternalCertificateAuthoritySchema,@@ -19,7 +20,8 @@ const CertificateAuthoritySchema = z.discriminatedUnion("type", [AzureAdCsCertificateAuthoritySchema,AwsPcaCertificateAuthoritySchema,DigiCertCertificateAuthoritySchema,- AwsAcmPublicCaCertificateAuthoritySchema+ AwsAcmPublicCaCertificateAuthoritySchema,+ VenafiTppCertificateAuthoritySchema]);export const registerGeneralCertificateAuthorityRouter = async (server: FastifyZodProvider) => {@@ -84,6 +86,7 @@ export const registerGeneralCertificateAuthorityRouter = async (server: FastifyZ},req.permission);+const awsAcmPublicCas = await server.services.certificateAuthority.listCertificateAuthoritiesByProjectId({projectId: req.query.projectId,@@ -92,6 +95,14 @@ export const registerGeneralCertificateAuthorityRouter = async (server: FastifyZreq.permission);+ const venafiTppCas = await server.services.certificateAuthority.listCertificateAuthoritiesByProjectId(+ {+ projectId: req.query.projectId,+ type: CaType.VENAFI_TPP+ },+ req.permission+ );+await server.services.auditLog.createAuditLog({...req.auditLogInfo,projectId: req.query.projectId,@@ -104,7 +115,8 @@ export const registerGeneralCertificateAuthorityRouter = async (server: FastifyZ...(azureAdCsCas ?? []).map((ca) => ca.id),...(awsPcaCas ?? []).map((ca) => ca.id),...(digicertCas ?? []).map((ca) => ca.id),- ...(awsAcmPublicCas ?? []).map((ca) => ca.id)+ ...(awsAcmPublicCas ?? []).map((ca) => ca.id),+ ...(venafiTppCas ?? []).map((ca) => ca.id)]}}@@ -117,7 +129,8 @@ export const registerGeneralCertificateAuthorityRouter = async (server: FastifyZ...(azureAdCsCas ?? []),...(awsPcaCas ?? []),...(digicertCas ?? []),- ...(awsAcmPublicCas ?? [])+ ...(awsAcmPublicCas ?? []),+ ...(venafiTppCas ?? [])]};}diff --git a/backend/src/server/routes/v1/certificate-authority-routers/index.ts b/backend/src/server/routes/v1/certificate-authority-routers/index.tsindex 93a9a5fca3..2e34156748 100644--- a/backend/src/server/routes/v1/certificate-authority-routers/index.ts+++ b/backend/src/server/routes/v1/certificate-authority-routers/index.ts@@ -6,6 +6,7 @@ import { registerAwsPcaCertificateAuthorityRouter } from "./aws-pca-certificate-import { registerAzureAdCsCertificateAuthorityRouter } from "./azure-ad-cs-certificate-authority-router";import { registerDigiCertCertificateAuthorityRouter } from "./digicert-certificate-authority-router";import { registerInternalCertificateAuthorityRouter } from "./internal-certificate-authority-router";+import { registerVenafiTppCertificateAuthorityRouter } from "./venafi-tpp-certificate-authority-router";export * from "./internal-certificate-authority-router";@@ -16,5 +17,6 @@ export const CERTIFICATE_AUTHORITY_REGISTER_ROUTER_MAP: Record<CaType, (server:[CaType.AZURE_AD_CS]: registerAzureAdCsCertificateAuthorityRouter,[CaType.AWS_PCA]: registerAwsPcaCertificateAuthorityRouter,[CaType.DIGICERT]: registerDigiCertCertificateAuthorityRouter,- [CaType.AWS_ACM_PUBLIC_CA]: registerAwsAcmPublicCaCertificateAuthorityRouter+ [CaType.AWS_ACM_PUBLIC_CA]: registerAwsAcmPublicCaCertificateAuthorityRouter,+ [CaType.VENAFI_TPP]: registerVenafiTppCertificateAuthorityRouter};diff --git a/backend/src/server/routes/v1/certificate-authority-routers/venafi-tpp-certificate-authority-router.ts b/backend/src/server/routes/v1/certificate-authority-routers/venafi-tpp-certificate-authority-router.tsnew file mode 100644index 0000000000..5e3c45ccfd--- /dev/null+++ b/backend/src/server/routes/v1/certificate-authority-routers/venafi-tpp-certificate-authority-router.ts@@ -0,0 +1,18 @@+import { CaType } from "@app/services/certificate-authority/certificate-authority-enums";+import {+ CreateVenafiTppCertificateAuthoritySchema,+ UpdateVenafiTppCertificateAuthoritySchema,+ VenafiTppCertificateAuthoritySchema+} from "@app/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-schemas";++import { registerCertificateAuthorityEndpoints } from "./certificate-authority-endpoints";++export const registerVenafiTppCertificateAuthorityRouter = async (server: FastifyZodProvider) => {+ registerCertificateAuthorityEndpoints({+ caType: CaType.VENAFI_TPP,+ server,+ responseSchema: VenafiTppCertificateAuthoritySchema,+ createSchema: CreateVenafiTppCertificateAuthoritySchema,+ updateSchema: UpdateVenafiTppCertificateAuthoritySchema+ });+};diff --git a/backend/src/server/routes/v2/certificate-authority-router.ts b/backend/src/server/routes/v2/certificate-authority-router.tsindex 3501fb5775..51fe7a2095 100644--- a/backend/src/server/routes/v2/certificate-authority-router.ts+++ b/backend/src/server/routes/v2/certificate-authority-router.ts@@ -12,6 +12,7 @@ import { AzureAdCsCertificateAuthoritySchema } from "@app/services/certificate-aimport { CaType } from "@app/services/certificate-authority/certificate-authority-enums";import { DigiCertCertificateAuthoritySchema } from "@app/services/certificate-authority/digicert/digicert-certificate-authority-schemas";import { InternalCertificateAuthoritySchema } from "@app/services/certificate-authority/internal/internal-certificate-authority-schemas";+import { VenafiTppCertificateAuthoritySchema } from "@app/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-schemas";const CertificateAuthoritySchema = z.discriminatedUnion("type", [InternalCertificateAuthoritySchema,@@ -19,7 +20,8 @@ const CertificateAuthoritySchema = z.discriminatedUnion("type", [AzureAdCsCertificateAuthoritySchema,AwsPcaCertificateAuthoritySchema,DigiCertCertificateAuthoritySchema,- AwsAcmPublicCaCertificateAuthoritySchema+ AwsAcmPublicCaCertificateAuthoritySchema,+ VenafiTppCertificateAuthoritySchema]);export const registerCaRouter = async (server: FastifyZodProvider) => {@@ -84,6 +86,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {},req.permission);+const awsAcmPublicCas = await server.services.certificateAuthority.listCertificateAuthoritiesByProjectId({projectId: req.query.projectId,@@ -92,6 +95,14 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {req.permission);+ const venafiTppCas = await server.services.certificateAuthority.listCertificateAuthoritiesByProjectId(+ {+ projectId: req.query.projectId,+ type: CaType.VENAFI_TPP+ },+ req.permission+ );+await server.services.auditLog.createAuditLog({...req.auditLogInfo,projectId: req.query.projectId,@@ -104,7 +115,8 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {...(azureAdCsCas ?? []).map((ca) => ca.id),...(awsPcaCas ?? []).map((ca) => ca.id),...(digicertCas ?? []).map((ca) => ca.id),- ...(awsAcmPublicCas ?? []).map((ca) => ca.id)+ ...(awsAcmPublicCas ?? []).map((ca) => ca.id),+ ...(venafiTppCas ?? []).map((ca) => ca.id)]}}@@ -117,7 +129,8 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {...(azureAdCsCas ?? []),...(awsPcaCas ?? []),...(digicertCas ?? []),- ...(awsAcmPublicCas ?? [])+ ...(awsAcmPublicCas ?? []),+ ...(venafiTppCas ?? [])]};}diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.tsindex f7a8ca033e..9699f93854 100644--- a/backend/src/services/app-connection/app-connection-enums.ts+++ b/backend/src/services/app-connection/app-connection-enums.ts@@ -52,6 +52,7 @@ export enum AppConnection {CircleCI = "circleci",AzureEntraId = "azure-entra-id",Venafi = "venafi",+ VenafiTpp = "venafi-tpp",ExternalInfisical = "external-infisical",Doppler = "doppler",NetScaler = "netscaler",diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.tsindex 8ec023220b..d8edfc09a1 100644--- a/backend/src/services/app-connection/app-connection-fns.ts+++ b/backend/src/services/app-connection/app-connection-fns.ts@@ -213,6 +213,11 @@ import {validateTravisCIConnectionCredentials} from "./travis-ci";import { getVenafiConnectionListItem, validateVenafiConnectionCredentials, VenafiConnectionMethod } from "./venafi";+import {+ getVenafiTppConnectionListItem,+ validateVenafiTppConnectionCredentials,+ VenafiTppConnectionMethod+} from "./venafi-tpp";import { VercelConnectionMethod } from "./vercel";import { getVercelConnectionListItem, validateVercelConnectionCredentials } from "./vercel/vercel-connection-fns";import {@@ -244,6 +249,7 @@ const PKI_APP_CONNECTIONS = [AppConnection.DNSMadeEasy,AppConnection.AzureDNS,AppConnection.Venafi,+ AppConnection.VenafiTpp,AppConnection.NetScaler,AppConnection.DigiCert];@@ -304,6 +310,7 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {getCircleCIConnectionListItem(),getAzureEntraIdConnectionListItem(),getVenafiConnectionListItem(),+ getVenafiTppConnectionListItem(),getExternalInfisicalConnectionListItem(),getDopplerConnectionListItem(),getNetScalerConnectionListItem(),@@ -455,6 +462,7 @@ export const validateAppConnectionCredentials = async ([AppConnection.CircleCI]: validateCircleCIConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.AzureEntraId]: validateAzureEntraIdConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.Venafi]: validateVenafiConnectionCredentials as TAppConnectionCredentialsValidator,+ [AppConnection.VenafiTpp]: validateVenafiTppConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.NetScaler]: validateNetScalerConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.Ona]: validateOnaConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.TravisCI]: validateTravisCIConnectionCredentials as TAppConnectionCredentialsValidator,@@ -526,6 +534,7 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>case AzureADCSConnectionMethod.UsernamePassword:case RedisConnectionMethod.UsernameAndPassword:case MongoDBConnectionMethod.UsernameAndPassword:+ case VenafiTppConnectionMethod.UsernamePassword:return "Username & Password";case WindmillConnectionMethod.AccessToken:case HCVaultConnectionMethod.AccessToken:@@ -671,6 +680,7 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<[AppConnection.CircleCI]: platformManagedCredentialsNotSupported,[AppConnection.AzureEntraId]: platformManagedCredentialsNotSupported,[AppConnection.Venafi]: platformManagedCredentialsNotSupported,+ [AppConnection.VenafiTpp]: platformManagedCredentialsNotSupported,[AppConnection.ExternalInfisical]: platformManagedCredentialsNotSupported,[AppConnection.NetScaler]: platformManagedCredentialsNotSupported,[AppConnection.Doppler]: platformManagedCredentialsNotSupported,diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.tsindex a04b831a1d..645ad41cb1 100644--- a/backend/src/services/app-connection/app-connection-maps.ts+++ b/backend/src/services/app-connection/app-connection-maps.ts@@ -54,6 +54,7 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {[AppConnection.CircleCI]: "CircleCI",[AppConnection.AzureEntraId]: "Azure Entra ID",[AppConnection.Venafi]: "Venafi TLS Protect Cloud",+ [AppConnection.VenafiTpp]: "Venafi TPP",[AppConnection.ExternalInfisical]: "Infisical",[AppConnection.Doppler]: "Doppler",[AppConnection.NetScaler]: "NetScaler",@@ -117,6 +118,7 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp[AppConnection.CircleCI]: AppConnectionPlanType.Regular,[AppConnection.AzureEntraId]: AppConnectionPlanType.Regular,[AppConnection.Venafi]: AppConnectionPlanType.Regular,+ [AppConnection.VenafiTpp]: AppConnectionPlanType.Regular,[AppConnection.ExternalInfisical]: AppConnectionPlanType.Regular,[AppConnection.Doppler]: AppConnectionPlanType.Regular,[AppConnection.NetScaler]: AppConnectionPlanType.Regular,diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.tsindex 228e5f6bd1..f0a3268c27 100644--- a/backend/src/services/app-connection/app-connection-service.ts+++ b/backend/src/services/app-connection/app-connection-service.ts@@ -148,6 +148,7 @@ import { ValidateTravisCIConnectionCredentialsSchema } from "./travis-ci";import { travisCIConnectionService } from "./travis-ci/travis-ci-connection-service";import { ValidateVenafiConnectionCredentialsSchema } from "./venafi/venafi-connection-schema";import { venafiConnectionService } from "./venafi/venafi-connection-service";+import { ValidateVenafiTppConnectionCredentialsSchema } from "./venafi-tpp/venafi-tpp-connection-schemas";import { ValidateVercelConnectionCredentialsSchema } from "./vercel";import { vercelConnectionService } from "./vercel/vercel-connection-service";import { ValidateWindmillConnectionCredentialsSchema } from "./windmill";@@ -225,6 +226,7 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp[AppConnection.CircleCI]: ValidateCircleCIConnectionCredentialsSchema,[AppConnection.AzureEntraId]: ValidateAzureEntraIdConnectionCredentialsSchema,[AppConnection.Venafi]: ValidateVenafiConnectionCredentialsSchema,+ [AppConnection.VenafiTpp]: ValidateVenafiTppConnectionCredentialsSchema,[AppConnection.ExternalInfisical]: ValidateExternalInfisicalConnectionCredentialsSchema,[AppConnection.Doppler]: ValidateDopplerConnectionCredentialsSchema,[AppConnection.NetScaler]: ValidateNetScalerConnectionCredentialsSchema,diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.tsindex 8751902101..82eb81c834 100644--- a/backend/src/services/app-connection/app-connection-types.ts+++ b/backend/src/services/app-connection/app-connection-types.ts@@ -335,6 +335,12 @@ import {TVenafiConnectionConfig,TVenafiConnectionInput} from "./venafi";+import {+ TValidateVenafiTppConnectionCredentialsSchema,+ TVenafiTppConnection,+ TVenafiTppConnectionConfig,+ TVenafiTppConnectionInput+} from "./venafi-tpp";import {TValidateVercelConnectionCredentialsSchema,TVercelConnection,@@ -408,6 +414,7 @@ export type TAppConnection = { id: string } & (| TCircleCIConnection| TAzureEntraIdConnection| TVenafiConnection+ | TVenafiTppConnection| TExternalInfisicalConnection| TDopplerConnection| TNetScalerConnection@@ -479,6 +486,7 @@ export type TAppConnectionInput = { id: string } & (| TCircleCIConnectionInput| TAzureEntraIdConnectionInput| TVenafiConnectionInput+ | TVenafiTppConnectionInput| TExternalInfisicalConnectionInput| TDopplerConnectionInput| TNetScalerConnectionInput@@ -579,6 +587,7 @@ export type TAppConnectionConfig =| TCircleCIConnectionConfig| TAzureEntraIdConnectionConfig| TVenafiConnectionConfig+ | TVenafiTppConnectionConfig| TExternalInfisicalConnectionConfig| TDopplerConnectionConfig| TNetScalerConnectionConfig@@ -641,6 +650,7 @@ export type TValidateAppConnectionCredentialsSchema =| TValidateCircleCIConnectionCredentialsSchema| TValidateAzureEntraIdConnectionCredentialsSchema| TValidateVenafiConnectionCredentialsSchema+ | TValidateVenafiTppConnectionCredentialsSchema| TValidateExternalInfisicalConnectionCredentialsSchema| TValidateDopplerConnectionCredentialsSchema| TValidateNetScalerConnectionCredentialsSchemadiff --git a/backend/src/services/app-connection/venafi-tpp/index.ts b/backend/src/services/app-connection/venafi-tpp/index.tsnew file mode 100644index 0000000000..596acec3f7--- /dev/null+++ b/backend/src/services/app-connection/venafi-tpp/index.ts@@ -0,0 +1,4 @@+export * from "./venafi-tpp-connection-enums";+export * from "./venafi-tpp-connection-fns";+export * from "./venafi-tpp-connection-schemas";+export * from "./venafi-tpp-connection-types";diff --git a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-enums.ts b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-enums.tsnew file mode 100644index 0000000000..fe6a1ca246--- /dev/null+++ b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-enums.ts@@ -0,0 +1,3 @@+export enum VenafiTppConnectionMethod {+ UsernamePassword = "username-password"+}diff --git a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-fns.ts b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-fns.tsnew file mode 100644index 0000000000..e4360c08cb--- /dev/null+++ b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-fns.ts@@ -0,0 +1,150 @@+import { AxiosError } from "axios";+import RE2 from "re2";++import { request } from "@app/lib/config/request";+import { BadRequestError } from "@app/lib/errors";+import { logger } from "@app/lib/logger";+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator/validate-url";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++import { VenafiTppConnectionMethod } from "./venafi-tpp-connection-enums";+import { TVenafiTppConnectionConfig } from "./venafi-tpp-connection-types";++type TVenafiTppCredentials = {+ tppUrl: string;+ clientId: string;+ username: string;+ password: string;+};++type TVenafiTppOAuthResponse = {+ access_token: string;+ refresh_token: string;+ expires_in: number;+ expires: number;+ token_type: string;+ scope: string;+ identity: string;+};++/**+ * Normalizes the TPP base URL by removing trailing slashes+ */+const normalizeTppUrl = (tppUrl: string): string => {+ return tppUrl.replace(new RE2("\\/+$"), "");+};++/**+ * Authenticates with Venafi TPP via OAuth and returns an access token.+ */+export const authenticateVenafiTpp = async ({+ tppUrl,+ clientId,+ username,+ password+}: TVenafiTppCredentials): Promise<TVenafiTppOAuthResponse> => {+ const baseUrl = normalizeTppUrl(tppUrl);++ logger.info("Venafi TPP: Authenticating via OAuth token endpoint");++ const { data } = await request.post<TVenafiTppOAuthResponse>(`${baseUrl}/vedauth/authorize/oauth`, {+ client_id: clientId,+ username,+ password,+ scope: "certificate:manage,discover,revoke;configuration"+ });++ logger.info("Venafi TPP: Successfully obtained access token");++ return data;+};++/**+ * Revokes a Venafi TPP access token.+ */+export const revokeVenafiTppToken = async (tppUrl: string, accessToken: string): Promise<void> => {+ const baseUrl = normalizeTppUrl(tppUrl);++ try {+ await request.get(`${baseUrl}/vedauth/revoke/token`, {+ headers: {+ Authorization: `Bearer ${accessToken}`+ }+ });+ logger.info("Venafi TPP: Successfully revoked access token");+ } catch (error) {+ logger.warn(error, "Venafi TPP: Failed to revoke access token");+ }+};++export const getVenafiTppHeaders = (accessToken: string) => ({+ Authorization: `Bearer ${accessToken}`,+ "Content-Type": "application/json"+});++export const getVenafiTppConnectionListItem = () => {+ return {+ name: "Venafi TPP" as const,+ app: AppConnection.VenafiTpp as const,+ methods: Object.values(VenafiTppConnectionMethod) as [VenafiTppConnectionMethod.UsernamePassword]+ };+};++export const validateVenafiTppConnectionCredentials = async (config: TVenafiTppConnectionConfig) => {+ const { tppUrl, clientId, username, password } = config.credentials as TVenafiTppCredentials;+ const hasGateway = Boolean(config.gatewayId);++ const normalizedUrl = normalizeTppUrl(tppUrl);+ try {+ await blockLocalAndPrivateIpAddresses(normalizedUrl, hasGateway);+ } catch (error) {+ logger.error({ tppUrl, hasGateway }, "Venafi TPP: URL blocked by SSRF protection");+ throw error;+ }++ logger.info({ tppUrl }, "Venafi TPP: Validating connection credentials");++ let accessToken: string | undefined;+ try {+ const authResponse = await authenticateVenafiTpp({ tppUrl, clientId, username, password });+ accessToken = authResponse.access_token;++ logger.info(+ {+ tppUrl,+ identity: authResponse.identity,+ scope: authResponse.scope+ },+ "Venafi TPP: Credential validation successful"+ );+ } catch (error: unknown) {+ if (error instanceof BadRequestError) {+ throw error;+ }+ if (error instanceof AxiosError) {+ const statusCode = error.response?.status;+ const errorMessage =+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access+ (error.response?.data?.error_description as string) ||+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access+ (error.response?.data?.error as string) ||+ error.message;++ logger.error({ tppUrl, statusCode, errorMessage }, "Venafi TPP: Failed to validate credentials");++ throw new BadRequestError({+ message: `Failed to validate Venafi TPP credentials: ${errorMessage}`+ });+ }+ logger.error(error, "Venafi TPP: Unexpected error during credential validation");+ throw new BadRequestError({+ message: `Failed to validate Venafi TPP credentials: ${(error as Error)?.message || "Unknown error"}`+ });+ } finally {+ if (accessToken) {+ await revokeVenafiTppToken(tppUrl, accessToken);+ }+ }++ return config.credentials;+};diff --git a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-schemas.ts b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-schemas.tsnew file mode 100644index 0000000000..3cfe23779a--- /dev/null+++ b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-schemas.ts@@ -0,0 +1,89 @@+import z from "zod";++import { AppConnections } from "@app/lib/api-docs";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import {+ BaseAppConnectionSchema,+ GenericCreateAppConnectionFieldsSchema,+ GenericUpdateAppConnectionFieldsSchema+} from "@app/services/app-connection/app-connection-schemas";++import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps";+import { VenafiTppConnectionMethod } from "./venafi-tpp-connection-enums";++export const VenafiTppUsernamePasswordCredentialsSchema = z.object({+ tppUrl: z+ .string()+ .trim()+ .min(1, "TPP URL required")+ .max(512)+ .refine((value) => value.startsWith("https://"), "TPP URL must use HTTPS")+ .describe(AppConnections.CREDENTIALS.VENAFI_TPP.tppUrl),+ clientId: z+ .string()+ .trim()+ .min(1, "Client ID required")+ .max(255)+ .describe(AppConnections.CREDENTIALS.VENAFI_TPP.clientId),+ username: z+ .string()+ .trim()+ .min(1, "Username required")+ .max(255)+ .describe(AppConnections.CREDENTIALS.VENAFI_TPP.username),+ password: z+ .string()+ .trim()+ .min(1, "Password required")+ .max(255)+ .describe(AppConnections.CREDENTIALS.VENAFI_TPP.password)+});++const BaseVenafiTppConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.VenafiTpp) });++export const VenafiTppConnectionSchema = BaseVenafiTppConnectionSchema.extend({+ method: z.literal(VenafiTppConnectionMethod.UsernamePassword),+ credentials: VenafiTppUsernamePasswordCredentialsSchema+});++export const SanitizedVenafiTppConnectionSchema = z.discriminatedUnion("method", [+ BaseVenafiTppConnectionSchema.extend({+ method: z.literal(VenafiTppConnectionMethod.UsernamePassword),+ credentials: VenafiTppUsernamePasswordCredentialsSchema.pick({+ tppUrl: true,+ clientId: true,+ username: true+ })+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.VenafiTpp]} (Username and Password)` }))+]);++export const ValidateVenafiTppConnectionCredentialsSchema = z.discriminatedUnion("method", [+ z.object({+ method: z+ .literal(VenafiTppConnectionMethod.UsernamePassword)+ .describe(AppConnections.CREATE(AppConnection.VenafiTpp).method),+ credentials: VenafiTppUsernamePasswordCredentialsSchema.describe(+ AppConnections.CREATE(AppConnection.VenafiTpp).credentials+ )+ })+]);++export const CreateVenafiTppConnectionSchema = ValidateVenafiTppConnectionCredentialsSchema.and(+ GenericCreateAppConnectionFieldsSchema(AppConnection.VenafiTpp, { supportsGateways: true })+);++export const UpdateVenafiTppConnectionSchema = z+ .object({+ credentials: VenafiTppUsernamePasswordCredentialsSchema.optional().describe(+ AppConnections.UPDATE(AppConnection.VenafiTpp).credentials+ )+ })+ .and(GenericUpdateAppConnectionFieldsSchema(AppConnection.VenafiTpp, { supportsGateways: true }));++export const VenafiTppConnectionListItemSchema = z+ .object({+ name: z.literal("Venafi TPP"),+ app: z.literal(AppConnection.VenafiTpp),+ methods: z.nativeEnum(VenafiTppConnectionMethod).array()+ })+ .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.VenafiTpp] }));diff --git a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-types.ts b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-types.tsnew file mode 100644index 0000000000..5a4e665a40--- /dev/null+++ b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-types.ts@@ -0,0 +1,25 @@+import z from "zod";++import { DiscriminativePick } from "@app/lib/types";++import { AppConnection } from "../app-connection-enums";+import {+ CreateVenafiTppConnectionSchema,+ ValidateVenafiTppConnectionCredentialsSchema,+ VenafiTppConnectionSchema+} from "./venafi-tpp-connection-schemas";++export type TVenafiTppConnection = z.infer<typeof VenafiTppConnectionSchema>;++export type TVenafiTppConnectionInput = z.infer<typeof CreateVenafiTppConnectionSchema> & {+ app: AppConnection.VenafiTpp;+};++export type TValidateVenafiTppConnectionCredentialsSchema = typeof ValidateVenafiTppConnectionCredentialsSchema;++export type TVenafiTppConnectionConfig = DiscriminativePick<+ TVenafiTppConnectionInput,+ "method" | "app" | "credentials" | "gatewayId"+> & {+ orgId: string;+};diff --git a/backend/src/services/certificate-authority/certificate-authority-enums.ts b/backend/src/services/certificate-authority/certificate-authority-enums.tsindex aa44beba59..082017f196 100644--- a/backend/src/services/certificate-authority/certificate-authority-enums.ts+++ b/backend/src/services/certificate-authority/certificate-authority-enums.ts@@ -4,7 +4,8 @@ export enum CaType {AZURE_AD_CS = "azure-ad-cs",AWS_PCA = "aws-pca",DIGICERT = "digicert",- AWS_ACM_PUBLIC_CA = "aws-acm-public-ca"+ AWS_ACM_PUBLIC_CA = "aws-acm-public-ca",+ VENAFI_TPP = "venafi-tpp"}export enum InternalCaType {diff --git a/backend/src/services/certificate-authority/certificate-authority-maps.ts b/backend/src/services/certificate-authority/certificate-authority-maps.tsindex 9318af0ccf..460a2d7080 100644--- a/backend/src/services/certificate-authority/certificate-authority-maps.ts+++ b/backend/src/services/certificate-authority/certificate-authority-maps.ts@@ -6,7 +6,8 @@ export const CERTIFICATE_AUTHORITIES_TYPE_MAP: Record<CaType, string> = {[CaType.AZURE_AD_CS]: "Active Directory Certificate Service",[CaType.AWS_PCA]: "AWS Private Certificate Authority",[CaType.DIGICERT]: "DigiCert",- [CaType.AWS_ACM_PUBLIC_CA]: "AWS ACM Public CA"+ [CaType.AWS_ACM_PUBLIC_CA]: "AWS ACM Public CA",+ [CaType.VENAFI_TPP]: "Venafi Trust Protection Platform"};export const CERTIFICATE_AUTHORITIES_CAPABILITIES_MAP: Record<CaType, CaCapability[]> = {@@ -35,7 +36,8 @@ export const CERTIFICATE_AUTHORITIES_CAPABILITIES_MAP: Record<CaType, CaCapabiliCaCapability.ISSUE_CERTIFICATES,CaCapability.REVOKE_CERTIFICATES,CaCapability.RENEW_CERTIFICATES- ]+ ],+ [CaType.VENAFI_TPP]: [CaCapability.ISSUE_CERTIFICATES, CaCapability.RENEW_CERTIFICATES]};/**diff --git a/backend/src/services/certificate-authority/certificate-authority-service.ts b/backend/src/services/certificate-authority/certificate-authority-service.tsindex c77e9aac45..7afaa78ae0 100644--- a/backend/src/services/certificate-authority/certificate-authority-service.ts+++ b/backend/src/services/certificate-authority/certificate-authority-service.ts@@ -78,6 +78,14 @@ import {import { TExternalCertificateAuthorityDALFactory } from "./external-certificate-authority-dal";import { TInternalCertificateAuthorityServiceFactory } from "./internal/internal-certificate-authority-service";import { TCreateInternalCertificateAuthorityDTO } from "./internal/internal-certificate-authority-types";+import {+ castDbEntryToVenafiTppCertificateAuthority,+ VenafiTppCertificateAuthorityFns+} from "./venafi-tpp/venafi-tpp-certificate-authority-fns";+import {+ TCreateVenafiTppCertificateAuthorityDTO,+ TUpdateVenafiTppCertificateAuthorityDTO+} from "./venafi-tpp/venafi-tpp-certificate-authority-types";type TCertificateAuthorityServiceFactoryDep = {appConnectionDAL: Pick<TAppConnectionDALFactory, "findById" | "update" | "updateById">;@@ -169,6 +177,19 @@ export const certificateAuthorityServiceFactory = ({certificateProfileDAL});+ const venafiTppFns = VenafiTppCertificateAuthorityFns({+ appConnectionDAL,+ appConnectionService,+ certificateAuthorityDAL,+ externalCertificateAuthorityDAL,+ certificateDAL,+ certificateBodyDAL,+ certificateSecretDAL,+ kmsService,+ projectDAL,+ certificateProfileDAL+ });+const awsPcaFns = AwsPcaCertificateAuthorityFns({appConnectionDAL,appConnectionService,@@ -297,6 +318,15 @@ export const certificateAuthorityServiceFactory = ({actor});}+ if (type === CaType.VENAFI_TPP) {+ return venafiTppFns.createCertificateAuthority({+ name,+ projectId,+ configuration: configuration as TCreateVenafiTppCertificateAuthorityDTO["configuration"],+ status,+ actor+ });+ }throw new BadRequestError({ message: "Invalid certificate authority type" });};@@ -368,6 +398,10 @@ export const certificateAuthorityServiceFactory = ({return castDbEntryToAwsAcmPublicCaCertificateAuthority(certificateAuthority);}+ if (type === CaType.VENAFI_TPP) {+ return castDbEntryToVenafiTppCertificateAuthority(certificateAuthority);+ }+throw new BadRequestError({ message: "Invalid certificate authority type" });};@@ -438,10 +472,15 @@ export const certificateAuthorityServiceFactory = ({if (type === CaType.DIGICERT) {return castDbEntryToDigiCertCertificateAuthority(certificateAuthority);}+if (type === CaType.AWS_ACM_PUBLIC_CA) {return castDbEntryToAwsAcmPublicCaCertificateAuthority(certificateAuthority);}+ if (type === CaType.VENAFI_TPP) {+ return castDbEntryToVenafiTppCertificateAuthority(certificateAuthority);+ }+throw new BadRequestError({ message: "Invalid certificate authority type" });};@@ -512,6 +551,10 @@ export const certificateAuthorityServiceFactory = ({return awsAcmPublicCaFns.listCertificateAuthorities({ projectId, permissionFilters });}+ if (type === CaType.VENAFI_TPP) {+ return venafiTppFns.listCertificateAuthorities({ projectId, permissionFilters });+ }+throw new BadRequestError({ message: "Invalid certificate authority type" });};@@ -621,6 +664,16 @@ export const certificateAuthorityServiceFactory = ({});}+ if (type === CaType.VENAFI_TPP) {+ return venafiTppFns.updateCertificateAuthority({+ id: certificateAuthority.id,+ configuration: configuration as TUpdateVenafiTppCertificateAuthorityDTO["configuration"],+ actor,+ status,+ name+ });+ }+throw new BadRequestError({ message: "Invalid certificate authority type" });};@@ -692,6 +745,10 @@ export const certificateAuthorityServiceFactory = ({return castDbEntryToAwsAcmPublicCaCertificateAuthority(certificateAuthority);}+ if (type === CaType.VENAFI_TPP) {+ return castDbEntryToVenafiTppCertificateAuthority(certificateAuthority);+ }+throw new BadRequestError({ message: "Invalid certificate authority type" });};@@ -804,6 +861,16 @@ export const certificateAuthorityServiceFactory = ({});}+ if (type === CaType.VENAFI_TPP) {+ return venafiTppFns.updateCertificateAuthority({+ id: certificateAuthority.id,+ configuration: configuration as TUpdateVenafiTppCertificateAuthorityDTO["configuration"],+ actor,+ status,+ name+ });+ }+throw new BadRequestError({ message: "Invalid certificate authority type" });};@@ -881,6 +948,10 @@ export const certificateAuthorityServiceFactory = ({return castDbEntryToAwsAcmPublicCaCertificateAuthority(certificateAuthority);}+ if (type === CaType.VENAFI_TPP) {+ return castDbEntryToVenafiTppCertificateAuthority(certificateAuthority);+ }+throw new BadRequestError({ message: "Invalid certificate authority type" });};diff --git a/backend/src/services/certificate-authority/certificate-authority-types.ts b/backend/src/services/certificate-authority/certificate-authority-types.tsindex 91bc7b3dd6..1d6fc551c4 100644--- a/backend/src/services/certificate-authority/certificate-authority-types.ts+++ b/backend/src/services/certificate-authority/certificate-authority-types.ts@@ -20,6 +20,10 @@ import {TInternalCertificateAuthority,TInternalCertificateAuthorityInput} from "./internal/internal-certificate-authority-types";+import {+ TCreateVenafiTppCertificateAuthorityDTO,+ TVenafiTppCertificateAuthority+} from "./venafi-tpp/venafi-tpp-certificate-authority-types";export type TCertificateAuthority =| TInternalCertificateAuthority@@ -27,7 +31,8 @@ export type TCertificateAuthority =| TAzureAdCsCertificateAuthority| TAwsPcaCertificateAuthority| TDigiCertCertificateAuthority- | TAwsAcmPublicCaCertificateAuthority;+ | TAwsAcmPublicCaCertificateAuthority+ | TVenafiTppCertificateAuthority;export type TCertificateAuthorityInput =| TInternalCertificateAuthorityInput@@ -35,7 +40,8 @@ export type TCertificateAuthorityInput =| TCreateAzureAdCsCertificateAuthorityDTO| TCreateAwsPcaCertificateAuthorityDTO| TCreateDigiCertCertificateAuthorityDTO- | TCreateAwsAcmPublicCaCertificateAuthorityDTO;+ | TCreateAwsAcmPublicCaCertificateAuthorityDTO+ | TCreateVenafiTppCertificateAuthorityDTO;export type TCreateCertificateAuthorityDTO = Omit<TCertificateAuthority, "id" | "enableDirectIssuance">;diff --git a/backend/src/services/certificate-authority/certificate-issuance-queue.ts b/backend/src/services/certificate-authority/certificate-issuance-queue.tsindex 06eff40424..e2a9f033f7 100644--- a/backend/src/services/certificate-authority/certificate-issuance-queue.ts+++ b/backend/src/services/certificate-authority/certificate-issuance-queue.ts@@ -42,6 +42,7 @@ import { CaType } from "./certificate-authority-enums";import { keyAlgorithmToAlgCfg } from "./certificate-authority-fns";import { DigiCertCertificateAuthorityFns } from "./digicert/digicert-certificate-authority-fns";import { TExternalCertificateAuthorityDALFactory } from "./external-certificate-authority-dal";+import { VenafiTppCertificateAuthorityFns } from "./venafi-tpp/venafi-tpp-certificate-authority-fns";const base64UrlToBase64 = (base64url: string): string => {let base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");@@ -200,6 +201,7 @@ export const certificateIssuanceQueueFactory = ({kmsService,projectDAL});+const awsAcmPublicCaFns = AwsAcmPublicCaCertificateAuthorityFns({appConnectionDAL,appConnectionService,@@ -213,6 +215,19 @@ export const certificateIssuanceQueueFactory = ({certificateProfileDAL});+ const venafiTppFns = VenafiTppCertificateAuthorityFns({+ appConnectionDAL,+ appConnectionService,+ certificateAuthorityDAL,+ externalCertificateAuthorityDAL,+ certificateDAL,+ certificateBodyDAL,+ certificateSecretDAL,+ kmsService,+ projectDAL,+ certificateProfileDAL+ });+/*** Queue a certificate issuance job.*/@@ -669,6 +684,63 @@ export const certificateIssuanceQueueFactory = ({`DigiCert order placed, awaiting validation [certificateRequestId=${certificateRequestId}] [orderId=${digicertResult.metadata.digicert.orderId}]`);}+ } else if (ca.externalCa?.type === CaType.VENAFI_TPP) {+ const venafiTppParams = {+ caId,+ profileId,+ commonName: commonName || "",+ altNames: (altNames || []).map((san: { type: string; value: string }) =>+ san.type ? `${san.type}:${san.value}` : san.value+ ),+ keyUsages: keyUsages as CertKeyUsage[],+ extendedKeyUsages: extendedKeyUsages as CertExtendedKeyUsage[],+ validity: { ttl },+ signatureAlgorithm,+ keyAlgorithm: keyAlgorithm as CertKeyAlgorithm,+ isRenewal,+ originalCertificateId,+ ...(csr && { csr }),+ organization,+ organizationalUnit,+ country,+ state,+ locality+ };++ const venafiTppResult = await venafiTppFns.orderCertificateFromProfile(venafiTppParams);++ if (certificateRequestId && certificateRequestService && venafiTppResult?.certificateId) {+ try {+ await certificateRequestService.attachCertificateToRequest({+ certificateRequestId,+ certificateId: venafiTppResult.certificateId+ });++ await copyMetadataFromRequestToCertificate(resourceMetadataDAL, {+ certificateRequestId,+ certificateId: venafiTppResult.certificateId+ });++ logger.info(`Certificate attached to request [certificateRequestId=${certificateRequestId}]`);+ } catch (attachError) {+ logger.error(+ attachError,+ `Failed to attach certificate to request [certificateRequestId=${certificateRequestId}]`+ );+ try {+ await certificateRequestService.updateCertificateRequestStatus({+ certificateRequestId,+ status: CertificateRequestStatus.FAILED,+ errorMessage: `Failed to attach certificate: ${attachError instanceof Error ? attachError.message : String(attachError)}`+ });+ } catch (statusUpdateError) {+ logger.error(+ statusUpdateError,+ `Failed to update certificate request status [certificateRequestId=${certificateRequestId}]`+ );+ }+ }+ }}logger.info(diff --git a/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.ts b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.tsnew file mode 100644index 0000000000..c48b1564d4--- /dev/null+++ b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.ts@@ -0,0 +1,993 @@+/* eslint-disable no-await-in-loop */+import * as x509 from "@peculiar/x509";+import { AxiosError } from "axios";+import RE2 from "re2";++import { TableName } from "@app/db/schemas";+import { request } from "@app/lib/config/request";+import { crypto } from "@app/lib/crypto/cryptography";+import { BadRequestError, NotFoundError } from "@app/lib/errors";+import { ProcessedPermissionRules } from "@app/lib/knex/permission-filter-utils";+import { logger } from "@app/lib/logger";+import { OrgServiceActor } from "@app/lib/types";+import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import { decryptAppConnectionCredentials } from "@app/services/app-connection/app-connection-fns";+import { TAppConnectionServiceFactory } from "@app/services/app-connection/app-connection-service";+import {+ authenticateVenafiTpp,+ getVenafiTppHeaders,+ revokeVenafiTppToken+} from "@app/services/app-connection/venafi-tpp/venafi-tpp-connection-fns";+import { TCertificateBodyDALFactory } from "@app/services/certificate/certificate-body-dal";+import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";+import { TCertificateSecretDALFactory } from "@app/services/certificate/certificate-secret-dal";+import {+ CertExtendedKeyUsage,+ CertKeyAlgorithm,+ CertKeyUsage,+ CertStatus,+ TAltNameType+} from "@app/services/certificate/certificate-types";+import { TCertificateProfileDALFactory } from "@app/services/certificate-profile/certificate-profile-dal";+import { TKmsServiceFactory } from "@app/services/kms/kms-service";+import { TProjectDALFactory } from "@app/services/project/project-dal";+import { getProjectKmsCertificateKeyId } from "@app/services/project/project-fns";++import { TCertificateAuthorityDALFactory } from "../certificate-authority-dal";+import { CaStatus, CaType } from "../certificate-authority-enums";+import { keyAlgorithmToAlgCfg } from "../certificate-authority-fns";+import { TExternalCertificateAuthorityDALFactory } from "../external-certificate-authority-dal";+import {+ TCreateVenafiTppCertificateAuthorityDTO,+ TUpdateVenafiTppCertificateAuthorityDTO,+ TVenafiTppCertificateAuthority+} from "./venafi-tpp-certificate-authority-types";++// -- SAN type codes for Venafi TPP SubjectAltNames --+const VENAFI_SAN_TYPE_DNS = 2;+const VENAFI_SAN_TYPE_IP = 7;+const VENAFI_SAN_TYPE_EMAIL = 1;+const VENAFI_SAN_TYPE_URI = 6;++type TVenafiTppCertificateRequest = {+ PolicyDN: string;+ PKCS10: string;+ ObjectName: string;+ SubjectAltNames?: Array<{ Type: number; Name: string }>;+ Origin?: string;+ CASpecificAttributes?: Array<{ Name: string; Value: string }>;+ WorkToDoTimeout?: number;+ DisableAutomaticRenewal?: boolean;+};++type TVenafiTppRequestResponse = {+ CertificateDN: string;+ Guid: string;+ CertificateData?: string;+ Filename?: string;+ Format?: string;+};++type TVenafiTppRetrieveResponse = {+ CertificateData: string;+ Filename: string;+ Format: string;+};++const parseTtlToDays = (ttl: string): number => {+ const match = ttl.match(new RE2("^(\\d+)([dhm])$"));+ if (!match) {+ throw new BadRequestError({+ message: `Invalid TTL format: ${ttl}. Expected format like '365d', '24h', or '60m'.`+ });+ }+ const value = parseInt(match[1], 10);+ const unit = match[2];+ switch (unit) {+ case "d":+ return value;+ case "h":+ return Math.max(1, Math.ceil(value / 24));+ case "m":+ return Math.max(1, Math.ceil(value / (24 * 60)));+ default:+ return value;+ }+};++const calculateFinalRenewBeforeDays = (+ profile: { apiConfig?: { autoRenew?: boolean; renewBeforeDays?: number } } | undefined,+ ttl: string+): number | undefined => {+ const hasAutoRenewEnabled = profile?.apiConfig?.autoRenew === true;+ if (!hasAutoRenewEnabled) {+ return undefined;+ }++ const profileRenewBeforeDays = profile?.apiConfig?.renewBeforeDays;+ if (profileRenewBeforeDays !== undefined) {+ const certificateTtlInDays = parseTtlToDays(ttl);+ if (profileRenewBeforeDays >= certificateTtlInDays) {+ return Math.max(1, certificateTtlInDays - 1);+ }+ return profileRenewBeforeDays;+ }++ return undefined;+};++const normalizeTppUrl = (tppUrl: string): string => {+ return tppUrl.replace(new RE2("\\/+$"), "");+};++/**+ * Parses a SAN string (e.g., "dns:example.com" or just "example.com") into Venafi TPP SAN format.+ */+const parseSanToVenafiFormat = (san: string): { Type: number; Name: string } | null => {+ const colonIdx = san.indexOf(":");+ if (colonIdx > 0) {+ const prefix = san.substring(0, colonIdx).toLowerCase();+ const value = san.substring(colonIdx + 1);+ switch (prefix) {+ case "dns":+ return { Type: VENAFI_SAN_TYPE_DNS, Name: value };+ case "ip":+ return { Type: VENAFI_SAN_TYPE_IP, Name: value };+ case "email":+ return { Type: VENAFI_SAN_TYPE_EMAIL, Name: value };+ case "uri":+ return { Type: VENAFI_SAN_TYPE_URI, Name: value };+ default:+ return { Type: VENAFI_SAN_TYPE_DNS, Name: san };+ }+ }++ if (san.match(new RE2("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$"))) {+ return { Type: VENAFI_SAN_TYPE_IP, Name: san };+ }++ return { Type: VENAFI_SAN_TYPE_DNS, Name: san };+};++const getVenafiTppConnectionCredentials = async (+ appConnectionId: string,+ appConnectionDAL: Pick<TAppConnectionDALFactory, "findById">,+ kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">+) => {+ const appConnection = await appConnectionDAL.findById(appConnectionId);+ if (!appConnection) {+ logger.error({ appConnectionId }, "Venafi TPP: App connection not found for credential decryption");+ throw new NotFoundError({ message: `App connection with ID '${appConnectionId}' not found` });+ }++ if (appConnection.app !== AppConnection.VenafiTpp) {+ logger.error(+ { appConnectionId, actualApp: appConnection.app },+ "Venafi TPP: App connection is not a Venafi TPP connection"+ );+ throw new BadRequestError({+ message: `Connection with ID '${appConnectionId}' is not a Venafi TPP connection`+ });+ }++ if (!appConnection.encryptedCredentials) {+ logger.error({ appConnectionId }, "Venafi TPP: App connection has no encrypted credentials");+ throw new BadRequestError({ message: "App connection has no stored credentials" });+ }++ const credentials = (await decryptAppConnectionCredentials({+ orgId: appConnection.orgId,+ kmsService,+ encryptedCredentials: appConnection.encryptedCredentials,+ projectId: appConnection.projectId+ })) as {+ tppUrl: string;+ clientId: string;+ username: string;+ password: string;+ };++ return credentials;+};++const submitCertificateToTpp = async ({+ baseUrl,+ accessToken,+ policyDN,+ csrPem,+ objectName,+ altNames,+ workToDoTimeout = 30+}: {+ baseUrl: string;+ accessToken: string;+ policyDN: string;+ csrPem: string;+ objectName: string;+ altNames?: string[];+ workToDoTimeout?: number;+}): Promise<TVenafiTppRequestResponse> => {+ const requestBody: TVenafiTppCertificateRequest = {+ PolicyDN: policyDN,+ PKCS10: csrPem,+ ObjectName: objectName,+ Origin: "Infisical",+ DisableAutomaticRenewal: true,+ WorkToDoTimeout: workToDoTimeout+ };++ if (altNames && altNames.length > 0) {+ const venafiSans = altNames.map((san) => parseSanToVenafiFormat(san)).filter(Boolean) as Array<{+ Type: number;+ Name: string;+ }>;+ if (venafiSans.length > 0) {+ requestBody.SubjectAltNames = venafiSans;+ }+ }++ logger.info(+ {+ policyDN,+ objectName,+ sanCount: requestBody.SubjectAltNames?.length ?? 0+ },+ "Venafi TPP: Submitting certificate request"+ );++ const { data, status } = await request.post<TVenafiTppRequestResponse>(+ `${baseUrl}/vedsdk/certificates/request`,+ requestBody,+ {+ headers: getVenafiTppHeaders(accessToken),+ validateStatus: (s) => s === 200 || s === 202+ }+ );++ logger.info(+ {+ certificateDN: data.CertificateDN,+ guid: data.Guid,+ httpStatus: status,+ hasCertificateData: !!data.CertificateData+ },+ "Venafi TPP: Certificate request submitted"+ );++ return data;+};++const retrieveCertificateFromTpp = async ({+ baseUrl,+ accessToken,+ certificateDN,+ includeChain = true+}: {+ baseUrl: string;+ accessToken: string;+ certificateDN: string;+ includeChain?: boolean;+}): Promise<{ certificate: string; chain: string }> => {+ logger.info({ certificateDN, includeChain }, "Venafi TPP: Retrieving certificate");++ const { data, status } = await request.post<TVenafiTppRetrieveResponse>(+ `${baseUrl}/vedsdk/certificates/retrieve`,+ {+ CertificateDN: certificateDN,+ Format: "Base64",+ IncludeChain: includeChain,+ IncludePrivateKey: false,+ RootFirstOrder: false+ },+ {+ headers: getVenafiTppHeaders(accessToken),+ validateStatus: (s) => s === 200 || s === 202+ }+ );++ if (status === 202) {+ logger.info({ certificateDN }, "Venafi TPP: Certificate not yet ready (202 Accepted)");+ throw new BadRequestError({+ message: "Certificate is not yet ready for retrieval. It may still be pending processing or approval."+ });+ }++ if (!data.CertificateData) {+ throw new BadRequestError({ message: "Venafi TPP returned empty certificate data" });+ }++ const decodedData = Buffer.from(data.CertificateData, "base64").toString("utf8");++ const certBlocks = decodedData.match(new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----", "g"));++ if (!certBlocks || certBlocks.length === 0) {+ throw new BadRequestError({ message: "Failed to parse certificate data from Venafi TPP response" });+ }++ const leafCert = certBlocks[0];+ const chainCerts = certBlocks.length > 1 ? certBlocks.slice(1).join("\n") : "";++ logger.info(+ {+ certificateDN,+ chainCertCount: certBlocks.length - 1+ },+ "Venafi TPP: Certificate retrieved successfully"+ );++ return {+ certificate: leafCert,+ chain: chainCerts+ };+};++export const castDbEntryToVenafiTppCertificateAuthority = (+ ca: Awaited<ReturnType<TCertificateAuthorityDALFactory["findByIdWithAssociatedCa"]>>+): TVenafiTppCertificateAuthority & { credentials: Buffer | null | undefined } => {+ if (!ca.externalCa?.id) {+ throw new BadRequestError({ message: "Malformed Venafi TPP certificate authority" });+ }++ if (!ca.externalCa.appConnectionId) {+ throw new BadRequestError({+ message: "Venafi TPP app connection ID is missing from certificate authority configuration"+ });+ }++ const configuration = ca.externalCa.configuration as { policyDN?: string } | null;++ if (!configuration?.policyDN) {+ throw new BadRequestError({+ message: "Venafi TPP policy DN is missing from certificate authority configuration"+ });+ }++ return {+ id: ca.id,+ type: CaType.VENAFI_TPP,+ enableDirectIssuance: ca.enableDirectIssuance,+ name: ca.name,+ projectId: ca.projectId,+ credentials: ca.externalCa.credentials,+ configuration: {+ appConnectionId: ca.externalCa.appConnectionId,+ policyDN: configuration.policyDN+ },+ status: ca.status as CaStatus+ };+};++type TVenafiTppCertificateAuthorityFnsDeps = {+ appConnectionDAL: Pick<TAppConnectionDALFactory, "findById" | "updateById">;+ appConnectionService: Pick<TAppConnectionServiceFactory, "validateAppConnectionUsageById">;+ certificateAuthorityDAL: Pick<+ TCertificateAuthorityDALFactory,+ "create" | "transaction" | "findByIdWithAssociatedCa" | "updateById" | "findWithAssociatedCa" | "findById"+ >;+ externalCertificateAuthorityDAL: Pick<TExternalCertificateAuthorityDALFactory, "create" | "update">;+ certificateDAL: Pick<TCertificateDALFactory, "create" | "transaction" | "updateById">;+ certificateBodyDAL: Pick<TCertificateBodyDALFactory, "create">;+ certificateSecretDAL: Pick<TCertificateSecretDALFactory, "create">;+ kmsService: Pick<TKmsServiceFactory, "encryptWithKmsKey" | "generateKmsKey" | "createCipherPairWithDataKey">;+ projectDAL: Pick<TProjectDALFactory, "findById" | "findOne" | "updateById" | "transaction">;+ certificateProfileDAL?: Pick<TCertificateProfileDALFactory, "findById">;+};++export const VenafiTppCertificateAuthorityFns = ({+ appConnectionDAL,+ appConnectionService,+ certificateAuthorityDAL,+ externalCertificateAuthorityDAL,+ certificateDAL,+ certificateBodyDAL,+ certificateSecretDAL,+ kmsService,+ projectDAL,+ certificateProfileDAL+}: TVenafiTppCertificateAuthorityFnsDeps) => {+ const createCertificateAuthority = async ({+ name,+ projectId,+ configuration,+ actor,+ status+ }: {+ status: CaStatus;+ name: string;+ projectId: string;+ configuration: TCreateVenafiTppCertificateAuthorityDTO["configuration"];+ actor: OrgServiceActor;+ }) => {+ const { appConnectionId, policyDN } = configuration;+ const appConnection = await appConnectionDAL.findById(appConnectionId);++ if (!appConnection) {+ throw new NotFoundError({ message: `App connection with ID '${appConnectionId}' not found` });+ }++ if (appConnection.app !== AppConnection.VenafiTpp) {+ throw new BadRequestError({+ message: `App connection with ID '${appConnectionId}' is not a Venafi TPP connection`+ });+ }++ await appConnectionService.validateAppConnectionUsageById(+ appConnection.app as AppConnection,+ { connectionId: appConnectionId, projectId },+ actor+ );++ logger.info({ projectId, appConnectionId, policyDN }, "Venafi TPP: Creating certificate authority");++ const caEntity = await certificateAuthorityDAL.transaction(async (tx) => {+ try {+ const ca = await certificateAuthorityDAL.create(+ {+ projectId,+ enableDirectIssuance: false,+ name,+ status+ },+ tx+ );++ await externalCertificateAuthorityDAL.create(+ {+ caId: ca.id,+ appConnectionId,+ type: CaType.VENAFI_TPP,+ configuration: { policyDN }+ },+ tx+ );++ return await certificateAuthorityDAL.findByIdWithAssociatedCa(ca.id, tx);+ } catch (error) {+ // 23505 = unique constraint violation+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any+ if ((error as any)?.error?.code === "23505") {+ throw new BadRequestError({+ message: "Certificate authority with the same name already exists in your project"+ });+ }+ throw error;+ }+ });++ if (!caEntity.externalCa?.id) {+ throw new BadRequestError({ message: "Failed to create Venafi TPP certificate authority" });+ }++ logger.info({ caId: caEntity.id, projectId }, "Venafi TPP: Certificate authority created successfully");++ return castDbEntryToVenafiTppCertificateAuthority(caEntity);+ };++ const updateCertificateAuthority = async ({+ id,+ configuration,+ actor,+ status,+ name+ }: {+ id: string;+ configuration?: TUpdateVenafiTppCertificateAuthorityDTO["configuration"];+ actor: OrgServiceActor;+ status?: CaStatus;+ name?: string;+ }) => {+ const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(id);+ if (!ca || !ca.externalCa) {+ throw new NotFoundError({ message: `Certificate authority with ID '${id}' not found` });+ }++ const updatedCa = await certificateAuthorityDAL.transaction(async (tx) => {+ if (configuration) {+ if (configuration.appConnectionId) {+ const appConnection = await appConnectionDAL.findById(configuration.appConnectionId);+ if (!appConnection) {+ throw new NotFoundError({+ message: `App connection with ID '${configuration.appConnectionId}' not found`+ });+ }+ if (appConnection.app !== AppConnection.VenafiTpp) {+ throw new BadRequestError({+ message: `App connection with ID '${configuration.appConnectionId}' is not a Venafi TPP connection`+ });+ }++ await appConnectionService.validateAppConnectionUsageById(+ appConnection.app as AppConnection,+ { connectionId: configuration.appConnectionId, projectId: ca.projectId },+ actor+ );+ }++ const existingConfig = (ca.externalCa?.configuration as { policyDN?: string } | null) || {};+ await externalCertificateAuthorityDAL.update(+ { caId: id, type: CaType.VENAFI_TPP },+ {+ ...(configuration.appConnectionId && { appConnectionId: configuration.appConnectionId }),+ configuration: {+ ...existingConfig,+ ...(configuration.policyDN && { policyDN: configuration.policyDN })+ }+ },+ tx+ );+ }++ if (name || status) {+ await certificateAuthorityDAL.updateById(+ id,+ {+ name,+ status+ },+ tx+ );+ }++ return certificateAuthorityDAL.findByIdWithAssociatedCa(id, tx);+ });++ if (!updatedCa.externalCa?.id) {+ throw new BadRequestError({ message: "Failed to update Venafi TPP certificate authority" });+ }++ return castDbEntryToVenafiTppCertificateAuthority(updatedCa);+ };++ const listCertificateAuthorities = async ({+ projectId,+ permissionFilters+ }: {+ projectId: string;+ permissionFilters?: ProcessedPermissionRules;+ }) => {+ const cas = await certificateAuthorityDAL.findWithAssociatedCa(+ {+ [`${TableName.CertificateAuthority}.projectId` as "projectId"]: projectId,+ [`${TableName.ExternalCertificateAuthority}.type` as "type"]: CaType.VENAFI_TPP+ },+ {},+ permissionFilters+ );++ return cas.map(castDbEntryToVenafiTppCertificateAuthority);+ };++ const orderCertificateFromProfile = async ({+ caId,+ profileId,+ commonName,+ altNames = [],+ keyUsages = [],+ extendedKeyUsages = [],+ validity,+ signatureAlgorithm,+ keyAlgorithm = CertKeyAlgorithm.RSA_2048,+ isRenewal,+ originalCertificateId,+ csr,+ organization,+ organizationalUnit,+ country,+ state,+ locality+ }: {+ caId: string;+ profileId: string;+ commonName: string;+ altNames?: string[];+ keyUsages?: CertKeyUsage[];+ extendedKeyUsages?: CertExtendedKeyUsage[];+ validity: { ttl: string };+ signatureAlgorithm?: string;+ keyAlgorithm?: CertKeyAlgorithm;+ isRenewal?: boolean;+ originalCertificateId?: string;+ csr?: string;+ organization?: string;+ organizationalUnit?: string;+ country?: string;+ state?: string;+ locality?: string;+ }) => {+ const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(caId);+ if (!ca.externalCa || ca.externalCa.type !== CaType.VENAFI_TPP) {+ logger.error(+ { caId, externalCaType: ca.externalCa?.type },+ "Venafi TPP: CA is not a Venafi TPP certificate authority"+ );+ throw new BadRequestError({ message: "CA is not a Venafi TPP certificate authority" });+ }++ const venafiCa = castDbEntryToVenafiTppCertificateAuthority(ca);+ if (venafiCa.status !== CaStatus.ACTIVE) {+ logger.error({ caId, status: venafiCa.status }, "Venafi TPP: Certificate authority is disabled");+ throw new BadRequestError({ message: "Certificate authority is disabled" });+ }++ logger.info(+ {+ caId,+ profileId,+ commonName,+ policyDN: venafiCa.configuration.policyDN,+ altNameCount: altNames.length+ },+ "Venafi TPP: Starting certificate order from profile"+ );++ const certificateManagerKmsId = await getProjectKmsCertificateKeyId({+ projectId: ca.projectId,+ projectDAL,+ kmsService+ });++ const kmsEncryptor = await kmsService.encryptWithKmsKey({+ kmsId: certificateManagerKmsId+ });++ const credentials = await getVenafiTppConnectionCredentials(+ venafiCa.configuration.appConnectionId,+ appConnectionDAL,+ kmsService+ );++ const baseUrl = normalizeTppUrl(credentials.tppUrl);++ let csrPem: string;+ let skLeaf: string | undefined;++ if (csr) {+ csrPem = csr;+ skLeaf = undefined;+ logger.info({ caId, commonName }, "Venafi TPP: Using user-provided CSR");+ } else {+ let alg;+ if (signatureAlgorithm) {+ switch (signatureAlgorithm.toUpperCase()) {+ case "RSA-SHA256":+ case "SHA256WITHRSA":+ alg = keyAlgorithmToAlgCfg(CertKeyAlgorithm.RSA_2048);+ break;+ case "RSA-SHA384":+ case "SHA384WITHRSA":+ alg = keyAlgorithmToAlgCfg(CertKeyAlgorithm.RSA_3072);+ break;+ case "RSA-SHA512":+ case "SHA512WITHRSA":+ alg = keyAlgorithmToAlgCfg(CertKeyAlgorithm.RSA_4096);+ break;+ case "ECDSA-SHA256":+ case "SHA256WITHECDSA":+ alg = keyAlgorithmToAlgCfg(CertKeyAlgorithm.ECDSA_P256);+ break;+ case "ECDSA-SHA384":+ case "SHA384WITHECDSA":+ alg = keyAlgorithmToAlgCfg(CertKeyAlgorithm.ECDSA_P384);+ break;+ case "ECDSA-SHA512":+ case "SHA512WITHECDSA":+ alg = keyAlgorithmToAlgCfg(CertKeyAlgorithm.ECDSA_P521);+ break;+ default:+ alg = keyAlgorithmToAlgCfg(keyAlgorithm);+ break;+ }+ } else {+ alg = keyAlgorithmToAlgCfg(keyAlgorithm);+ }++ const leafKeys = await crypto.nativeCrypto.subtle.generateKey(alg, true, ["sign", "verify"]);+ const skLeafObj = crypto.nativeCrypto.KeyObject.from(leafKeys.privateKey);+ skLeaf = skLeafObj.export({ format: "pem", type: "pkcs8" }) as string;++ const dnParts: string[] = [`CN=${commonName}`];+ if (organization) dnParts.push(`O=${organization}`);+ if (organizationalUnit) dnParts.push(`OU=${organizationalUnit}`);+ if (locality) dnParts.push(`L=${locality}`);+ if (state) dnParts.push(`ST=${state}`);+ if (country) dnParts.push(`C=${country}`);+ const subjectDN = dnParts.join(", ");++ const sanExtensions: x509.SubjectAlternativeNameExtension[] = [];+ if (altNames.length > 0) {+ const sanEntries: Array<{ type: TAltNameType; value: string }> = altNames.map((name) => {+ const colonIdx = name.indexOf(":");+ if (colonIdx > 0) {+ const prefix = name.substring(0, colonIdx).toLowerCase();+ const value = name.substring(colonIdx + 1);+ switch (prefix) {+ case "ip":+ return { type: "ip" as TAltNameType, value };+ case "email":+ return { type: "email" as TAltNameType, value };+ case "uri":+ return { type: "url" as TAltNameType, value };+ default:+ return { type: "dns" as TAltNameType, value: name };+ }+ }+ if (name.match(new RE2("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$"))) {+ return { type: "ip" as TAltNameType, value: name };+ }+ return { type: "dns" as TAltNameType, value: name };+ });++ sanExtensions.push(new x509.SubjectAlternativeNameExtension(sanEntries, false));+ }++ const csrObj = await x509.Pkcs10CertificateRequestGenerator.create({+ name: subjectDN,+ keys: leafKeys,+ signingAlgorithm: alg,+ ...(sanExtensions.length > 0 && { extensions: sanExtensions })+ });++ csrPem = csrObj.toString("pem");+ }++ let accessToken: string | undefined;++ try {+ const authResponse = await authenticateVenafiTpp({+ tppUrl: credentials.tppUrl,+ clientId: credentials.clientId,+ username: credentials.username,+ password: credentials.password+ });+ accessToken = authResponse.access_token;++ const requestResponse = await submitCertificateToTpp({+ baseUrl,+ accessToken,+ policyDN: venafiCa.configuration.policyDN,+ csrPem,+ objectName: commonName,+ altNames,+ workToDoTimeout: 60+ });++ let certificateResult: { certificate: string; chain: string } | undefined;++ if (requestResponse.CertificateData) {+ const decodedData = Buffer.from(requestResponse.CertificateData, "base64").toString("utf8");+ const certBlocks = decodedData.match(+ new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----", "g")+ );++ if (certBlocks && certBlocks.length > 0) {+ certificateResult = {+ certificate: certBlocks[0],+ chain: certBlocks.length > 1 ? certBlocks.slice(1).join("\n") : ""+ };+ }+ }++ if (!certificateResult) {+ const maxRetries = 10;+ const initialDelay = 3000;+ let lastError: Error | null = null;++ for (let attempt = 0; attempt < maxRetries; attempt += 1) {+ try {+ certificateResult = await retrieveCertificateFromTpp({+ baseUrl,+ accessToken,+ certificateDN: requestResponse.CertificateDN,+ includeChain: true+ });+ break;+ } catch (error) {+ lastError = error as Error;+ logger.warn(+ {+ attempt: attempt + 1,+ maxRetries,+ certificateDN: requestResponse.CertificateDN,+ error: (error as Error).message+ },+ "Venafi TPP: Certificate not yet available, retrying"+ );++ if (attempt < maxRetries - 1) {+ const delay = initialDelay * 2 ** attempt;+ await new Promise((resolve) => {+ setTimeout(resolve, Math.min(delay, 30000));+ });+ }+ }+ }++ if (!certificateResult) {+ logger.error(+ {+ caId,+ commonName,+ certificateDN: requestResponse.CertificateDN,+ maxRetries,+ lastError: lastError?.message+ },+ "Venafi TPP: Failed to retrieve certificate after all retry attempts"+ );+ throw new BadRequestError({+ message: `Certificate request submitted to Venafi TPP (DN: ${requestResponse.CertificateDN}) but failed to retrieve after ${maxRetries} attempts. The certificate may still be pending approval or processing. Last error: ${lastError?.message || "Unknown error"}`+ });+ }+ }++ let cleanedCertificatePem = certificateResult.certificate.trim();+ cleanedCertificatePem = cleanedCertificatePem+ .replace(new RE2("\\r\\n", "g"), "\n")+ .replace(new RE2("\\r", "g"), "\n")+ .trim();++ let certObj: x509.X509Certificate;+ try {+ certObj = new x509.X509Certificate(cleanedCertificatePem);+ } catch (error) {+ logger.error(+ {+ caId,+ commonName,+ certPemLength: cleanedCertificatePem.length,+ certPemStart: cleanedCertificatePem.substring(0, 100),+ parseError: error instanceof Error ? error.message : "Unknown error"+ },+ "Venafi TPP: Failed to parse certificate returned from TPP"+ );+ throw new BadRequestError({+ message: `Failed to parse certificate from Venafi TPP: ${error instanceof Error ? error.message : "Unknown error"}`+ });+ }++ logger.info(+ {+ serialNumber: certObj.serialNumber,+ subject: certObj.subject,+ notBefore: certObj.notBefore,+ notAfter: certObj.notAfter,+ caId+ },+ "Venafi TPP: Certificate issued successfully"+ );++ const { cipherTextBlob: encryptedCertificate } = await kmsEncryptor({+ plainText: Buffer.from(new Uint8Array(certObj.rawData))+ });++ const certificateChainPem = certificateResult.chain || "";++ const { cipherTextBlob: encryptedCertificateChain } = await kmsEncryptor({+ plainText: Buffer.from(certificateChainPem)+ });++ let certificateId: string;++ await certificateDAL.transaction(async (tx) => {+ const cert = await certificateDAL.create(+ {+ caId: ca.id,+ profileId,+ status: CertStatus.ACTIVE,+ friendlyName: commonName,+ commonName,+ altNames: altNames.join(","),+ serialNumber: certObj.serialNumber,+ notBefore: certObj.notBefore,+ notAfter: certObj.notAfter,+ keyUsages,+ extendedKeyUsages,+ keyAlgorithm,+ signatureAlgorithm,+ projectId: ca.projectId,+ renewedFromCertificateId: isRenewal && originalCertificateId ? originalCertificateId : null+ },+ tx+ );++ certificateId = cert.id;++ if (isRenewal && originalCertificateId) {+ await certificateDAL.updateById(originalCertificateId, { renewedByCertificateId: cert.id }, tx);+ }++ await certificateBodyDAL.create(+ {+ certId: cert.id,+ encryptedCertificate,+ encryptedCertificateChain+ },+ tx+ );++ if (skLeaf) {+ const { cipherTextBlob: encryptedPrivateKey } = await kmsEncryptor({+ plainText: Buffer.from(skLeaf)+ });++ await certificateSecretDAL.create(+ {+ certId: cert.id,+ encryptedPrivateKey+ },+ tx+ );+ }++ if (profileId && validity?.ttl && certificateProfileDAL) {+ const profile = await certificateProfileDAL.findById(profileId, tx);+ if (profile) {+ const finalRenewBeforeDays = calculateFinalRenewBeforeDays(undefined, validity.ttl);+ if (finalRenewBeforeDays !== undefined) {+ await certificateDAL.updateById(cert.id, { renewBeforeDays: finalRenewBeforeDays }, tx);+ }+ }+ }+ });++ logger.info(+ {+ certificateId: certificateId!,+ caId,+ commonName,+ serialNumber: certObj.serialNumber+ },+ "Venafi TPP: Certificate stored in database"+ );++ return {+ certificate: cleanedCertificatePem,+ certificateChain: certificateChainPem,+ privateKey: skLeaf || "",+ serialNumber: certObj.serialNumber,+ certificateId: certificateId!,+ ca: venafiCa+ };+ } catch (error: unknown) {+ if (error instanceof BadRequestError || error instanceof NotFoundError) {+ throw error;+ }+ if (error instanceof AxiosError) {+ const statusCode = error.response?.status;+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment+ const responseData = error.response?.data;++ logger.error(+ {+ statusCode,+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment+ responseData,+ caId,+ commonName+ },+ "Venafi TPP: Failed to issue certificate"+ );++ throw new BadRequestError({+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access+ message: `Venafi TPP certificate issuance failed: ${responseData?.Error || error.message}`+ });+ }+ logger.error(error, "Venafi TPP: Unexpected error during certificate issuance");+ throw new BadRequestError({+ message: `Venafi TPP certificate issuance failed: ${(error as Error)?.message || "Unknown error"}`+ });+ } finally {+ if (accessToken) {+ await revokeVenafiTppToken(baseUrl, accessToken);+ }+ }+ };++ return {+ createCertificateAuthority,+ updateCertificateAuthority,+ listCertificateAuthorities,+ orderCertificateFromProfile+ };+};diff --git a/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-schemas.ts b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-schemas.tsnew file mode 100644index 0000000000..ec4ff9cada--- /dev/null+++ b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-schemas.ts@@ -0,0 +1,34 @@+import { z } from "zod";++import { CaType } from "../certificate-authority-enums";+import {+ BaseCertificateAuthoritySchema,+ GenericCreateCertificateAuthorityFieldsSchema,+ GenericUpdateCertificateAuthorityFieldsSchema+} from "../certificate-authority-schemas";++export const VenafiTppCertificateAuthorityConfigurationSchema = z.object({+ appConnectionId: z.string().uuid().trim().describe("The Venafi TPP App Connection ID."),+ policyDN: z+ .string()+ .trim()+ .min(1, "Policy DN is required")+ .describe("The policy folder DN in Venafi TPP (e.g., '\\\\VED\\\\Policy\\\\Certificates').")+});++export const VenafiTppCertificateAuthoritySchema = BaseCertificateAuthoritySchema.extend({+ type: z.literal(CaType.VENAFI_TPP),+ configuration: VenafiTppCertificateAuthorityConfigurationSchema+});++export const CreateVenafiTppCertificateAuthoritySchema = GenericCreateCertificateAuthorityFieldsSchema(+ CaType.VENAFI_TPP+).extend({+ configuration: VenafiTppCertificateAuthorityConfigurationSchema+});++export const UpdateVenafiTppCertificateAuthoritySchema = GenericUpdateCertificateAuthorityFieldsSchema(+ CaType.VENAFI_TPP+).extend({+ configuration: VenafiTppCertificateAuthorityConfigurationSchema.optional()+});diff --git a/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-types.ts b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-types.tsnew file mode 100644index 0000000000..f53e74a3d6--- /dev/null+++ b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-types.ts@@ -0,0 +1,13 @@+import { z } from "zod";++import {+ CreateVenafiTppCertificateAuthoritySchema,+ UpdateVenafiTppCertificateAuthoritySchema,+ VenafiTppCertificateAuthoritySchema+} from "./venafi-tpp-certificate-authority-schemas";++export type TVenafiTppCertificateAuthority = z.infer<typeof VenafiTppCertificateAuthoritySchema>;++export type TCreateVenafiTppCertificateAuthorityDTO = z.infer<typeof CreateVenafiTppCertificateAuthoritySchema>;++export type TUpdateVenafiTppCertificateAuthorityDTO = z.infer<typeof UpdateVenafiTppCertificateAuthoritySchema>;diff --git a/backend/src/services/certificate-profile/certificate-profile-external-config-schemas.ts b/backend/src/services/certificate-profile/certificate-profile-external-config-schemas.tsindex a9e9aa1e95..f1542367f8 100644--- a/backend/src/services/certificate-profile/certificate-profile-external-config-schemas.ts+++ b/backend/src/services/certificate-profile/certificate-profile-external-config-schemas.ts@@ -32,6 +32,11 @@ export const DigiCertExternalConfigSchema = z.object({});*/export const AwsAcmPublicCaExternalConfigSchema = z.object({});+/**+ * External configuration schema for Venafi TPP Certificate Authority+ */+export const VenafiTppExternalConfigSchema = z.object({});+/*** Map of CA types to their corresponding external configuration schemas*/@@ -41,6 +46,7 @@ export const ExternalConfigSchemaMap = {[CaType.AWS_PCA]: AwsPcaExternalConfigSchema,[CaType.DIGICERT]: DigiCertExternalConfigSchema,[CaType.AWS_ACM_PUBLIC_CA]: AwsAcmPublicCaExternalConfigSchema,+ [CaType.VENAFI_TPP]: VenafiTppExternalConfigSchema,[CaType.INTERNAL]: z.object({}).optional() // Internal CAs don't use external configs} as const;@@ -67,6 +73,7 @@ export const ExternalConfigUnionSchema = zAwsPcaExternalConfigSchema,DigiCertExternalConfigSchema,AwsAcmPublicCaExternalConfigSchema,+ VenafiTppExternalConfigSchema,z.object({})]).nullable()diff --git a/backend/src/services/certificate-v3/certificate-approval-fns.ts b/backend/src/services/certificate-v3/certificate-approval-fns.tsindex 8dc5e6ddb0..36f07812fa 100644--- a/backend/src/services/certificate-v3/certificate-approval-fns.ts+++ b/backend/src/services/certificate-v3/certificate-approval-fns.ts@@ -443,7 +443,8 @@ export const certificateApprovalServiceFactory = (caType !== CaType.ACME &&caType !== CaType.AZURE_AD_CS &&caType !== CaType.AWS_PCA &&- caType !== CaType.AWS_ACM_PUBLIC_CA+ caType !== CaType.AWS_ACM_PUBLIC_CA &&+ caType !== CaType.VENAFI_TPP) {return null;}diff --git a/backend/src/services/certificate-v3/certificate-v3-service.ts b/backend/src/services/certificate-v3/certificate-v3-service.tsindex 4db3d3d9f7..773ccdf615 100644--- a/backend/src/services/certificate-v3/certificate-v3-service.ts+++ b/backend/src/services/certificate-v3/certificate-v3-service.ts@@ -282,7 +282,8 @@ const validateRenewalEligibility = (caType === CaType.AZURE_AD_CS ||caType === CaType.AWS_PCA ||caType === CaType.AWS_ACM_PUBLIC_CA ||- caType === CaType.DIGICERT;+ caType === CaType.DIGICERT ||+ caType === CaType.VENAFI_TPP;const isImportedCertificate = certificate.pkiSubscriberId != null && !certificate.profileId;if (!isInternalCa && !isConnectedExternalCa) {@@ -1886,7 +1887,8 @@ export const certificateV3ServiceFactory = ({caType === CaType.AZURE_AD_CS ||caType === CaType.AWS_PCA ||caType === CaType.DIGICERT ||- caType === CaType.AWS_ACM_PUBLIC_CA+ caType === CaType.AWS_ACM_PUBLIC_CA ||+ caType === CaType.VENAFI_TPP) {// Pre-flight validation for ACM — reject bad inputs synchronously so the user// gets a 400 on submit rather than a FAILED request row after the job runs.@@ -2239,7 +2241,8 @@ export const certificateV3ServiceFactory = ({caType === CaType.AZURE_AD_CS ||caType === CaType.AWS_PCA ||caType === CaType.DIGICERT ||- caType === CaType.AWS_ACM_PUBLIC_CA+ caType === CaType.AWS_ACM_PUBLIC_CA ||+ caType === CaType.VENAFI_TPP) {// External CA renewal - mark for async processing outside transactionreturn {diff --git a/docs/docs.json b/docs/docs.jsonindex 31d6e0dc0c..77bac72b99 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -161,6 +161,7 @@"integrations/app-connections/terraform-cloud","integrations/app-connections/travis-ci","integrations/app-connections/venafi",+ "integrations/app-connections/venafi-tpp","integrations/app-connections/vercel","integrations/app-connections/windmill","integrations/app-connections/smb",@@ -843,7 +844,8 @@"documentation/platform/pki/ca/azure-adcs","documentation/platform/pki/ca/aws-pca","documentation/platform/pki/ca/aws-acm-public-ca",- "documentation/platform/pki/ca/venafi"+ "documentation/platform/pki/ca/venafi",+ "documentation/platform/pki/ca/venafi-tpp"]}]diff --git a/docs/documentation/platform/pki/ca/venafi-tpp.mdx b/docs/documentation/platform/pki/ca/venafi-tpp.mdxnew file mode 100644index 0000000000..9761d1fb7b--- /dev/null+++ b/docs/documentation/platform/pki/ca/venafi-tpp.mdx@@ -0,0 +1,79 @@+---+title: "Venafi TPP"+description: "Learn how to issue and manage certificates using a self-hosted Venafi Trust Protection Platform (TPP) instance with Infisical."+---++Issue and manage certificates using a self-hosted Venafi Trust Protection Platform (TPP) instance as an external CA, with support for airgapped environments via Infisical Gateway.++## Prerequisites++- A [Venafi TPP Connection](/integrations/app-connections/venafi-tpp) configured in your organization+- A policy folder in your TPP instance configured with an appropriate CA template+- Network connectivity from Infisical (or an Infisical Gateway) to the TPP server++## Setting Up Venafi TPP as an External CA++<Steps>+ <Step title="Navigate to External Certificate Authorities">+ In your Infisical project, go to your **Certificate Project** > **Certificate Authority** to access the external CAs page.+ + </Step>+ <Step title="Create New Venafi TPP CA">+ Click **Create CA** and configure:++ - **Type**: Choose **Venafi TPP**+ - **Name**: A friendly name for this CA (e.g., "Production TPP CA")+ - **Status**: Set to **Active** to enable certificate issuance+ - **Venafi TPP Connection**: Select your TPP connection from the dropdown+ - **Policy DN**: The policy folder path in TPP where certificates will be managed (e.g., `\VED\Policy\Certificates\WebServers`)++ ++ <Note>+ The Policy DN must point to an existing policy folder in your TPP instance. The policy folder+ determines which CA template is used for signing, what subject fields are allowed, and other+ certificate constraints. Make sure the policy folder is configured to allow certificate requests+ from the credentials used in your TPP connection.+ </Note>+ </Step>+ <Step title="Certificate Authority Created">+ Your Venafi TPP CA is now ready. You can use it with certificate profiles to issue certificates.+ + </Step>+</Steps>++## Issuing Certificates++Once your Venafi TPP CA is set up, you issue certificates through **Certificate Profiles**:++<Steps>+ <Step title="Create a Certificate Profile">+ Go to **Policies** > **Certificate Profiles** and create a new profile:++ - Set the **Issuing CA** to your Venafi TPP CA+ - Configure the **Enrollment Method** as **API**+ - Set default certificate attributes (common name, SANs, key algorithm, TTL, etc.)++ + </Step>+ <Step title="Issue a Certificate">+ Go to **Certificates** and click **Issue Certificate**:++ - Select the profile linked to your Venafi TPP CA+ - Fill in the certificate details (common name, SANs, TTL)+ - Click **Issue**++ ++ The certificate request is submitted to TPP asynchronously. Infisical will authenticate with TPP, submit the CSR to the configured policy folder, and retrieve the signed certificate.++ <Note>+ Certificate issuance is asynchronous. Infisical will poll TPP for the signed certificate for+ up to ~5 minutes. Ensure your TPP policy folder is configured for automatic approval.+ </Note>+ </Step>+ <Step title="Certificate Issued">+ Your certificate has been issued by the TPP server and is ready for use.+ + </Step>+</Steps>diff --git a/docs/images/platform/pki/venafi-tpp/venafi-tpp-certificate-created.png b/docs/images/platform/pki/venafi-tpp/venafi-tpp-certificate-created.pngnew file mode 100644index 0000000000..5bccade961Binary files /dev/null and b/docs/images/platform/pki/venafi-tpp/venafi-tpp-certificate-created.png differdiff --git a/docs/images/platform/pki/venafi-tpp/venafi-tpp-external-ca-created.png b/docs/images/platform/pki/venafi-tpp/venafi-tpp-external-ca-created.pngnew file mode 100644index 0000000000..a2f85de95aBinary files /dev/null and b/docs/images/platform/pki/venafi-tpp/venafi-tpp-external-ca-created.png differdiff --git a/docs/images/platform/pki/venafi-tpp/venafi-tpp-external-ca-form.png b/docs/images/platform/pki/venafi-tpp/venafi-tpp-external-ca-form.pngnew file mode 100644index 0000000000..0b69a145cbBinary files /dev/null and b/docs/images/platform/pki/venafi-tpp/venafi-tpp-external-ca-form.png differdiff --git a/docs/images/platform/pki/venafi-tpp/venafi-tpp-external-ca-page.png b/docs/images/platform/pki/venafi-tpp/venafi-tpp-external-ca-page.pngnew file mode 100644index 0000000000..51efa9e6e5Binary files /dev/null and b/docs/images/platform/pki/venafi-tpp/venafi-tpp-external-ca-page.png differdiff --git a/docs/integrations/app-connections/venafi-tpp.mdx b/docs/integrations/app-connections/venafi-tpp.mdxnew file mode 100644index 0000000000..b1c1655b09--- /dev/null+++ b/docs/integrations/app-connections/venafi-tpp.mdx@@ -0,0 +1,63 @@+---+title: "Venafi TPP Connection"+description: "Learn how to configure a Venafi Trust Protection Platform (TPP) Connection for Infisical."+---++Connect Infisical to a self-hosted Venafi Trust Protection Platform (TPP) instance to use it as an external CA for certificate issuance and management.++## Prerequisites++- A self-hosted [Venafi Trust Protection Platform](https://venafi.com/) instance (on-premises or private cloud)+- An API Integration registered in your TPP instance with OAuth enabled+- A TPP user account with `certificate:manage,discover,revoke` and `configuration` scope privileges+- Network connectivity from Infisical to the TPP server (or an Infisical Gateway for airgapped environments)++<Note>+ To register an API Integration in Venafi TPP, navigate to **API** > **API Integrations** in the TPP web console+ and create a new integration with a Client ID. This Client ID is required when setting up the connection in Infisical.+</Note>++## Connection Setup++<Steps>+ <Step title="Navigate to App Connections">+ Navigate to the **App Connections** tab on the **Organization Settings** page.+ + </Step>+ <Step title="Add Connection">+ Select the **Venafi TPP** option from the connection options modal.+ + </Step>+ <Step title="Configure Connection Details">+ Configure the following fields:++ - **Name**: A friendly name for this connection (e.g., "Production TPP")+ - **Method**: The authentication method. Currently only **Username & Password** is supported.+ - **Gateway** *(optional)*: Select an Infisical Gateway if your TPP instance is in an airgapped network without direct internet access.+ - **TPP URL**: The HTTPS URL of your Venafi TPP instance (e.g., `https://tpp.example.com`). Must use HTTPS.+ - **Client ID**: The OAuth Client ID from your TPP API Integration.+ - **Username**: The TPP user account. Supports formats: `DOMAIN\username`, `[email protected]`, or local usernames.+ - **Password**: The password for the TPP user account.++ Click **Connect to Venafi TPP** to validate your credentials and create the connection.++ ++ <Note>+ Infisical validates the credentials by authenticating with the TPP OAuth endpoint during connection creation.+ If validation fails, verify that:+ - The TPP URL is correct and reachable+ - The Client ID matches an API Integration registered in TPP+ - The username and password are correct+ - The API Integration has the required scopes enabled+ </Note>+ </Step>+ <Step title="Connection Created">+ Your **Venafi TPP Connection** is now available for use as an external CA in your Infisical certificate management projects.+ + </Step>+</Steps>++## Gateway Support++For Venafi TPP instances running in airgapped or isolated networks, you can route the connection through an [Infisical Gateway](/documentation/platform/gateways/overview). Select the appropriate gateway when creating the connection to enable Infisical to reach your TPP server through a secure tunnel.diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.tsindex cd635b0c67..9b6518eef9 100644--- a/frontend/src/helpers/appConnections.ts+++ b/frontend/src/helpers/appConnections.ts@@ -75,6 +75,7 @@ import { SshConnectionMethod } from "@app/hooks/api/appConnections/types/ssh-conimport { SupabaseConnectionMethod } from "@app/hooks/api/appConnections/types/supabase-connection";import { TravisCIConnectionMethod } from "@app/hooks/api/appConnections/types/travis-ci-connection";import { VenafiConnectionMethod } from "@app/hooks/api/appConnections/types/venafi-connection";+import { VenafiTppConnectionMethod } from "@app/hooks/api/appConnections/types/venafi-tpp-connection";export const APP_CONNECTION_MAP: Record<AppConnection,@@ -163,6 +164,7 @@ export const APP_CONNECTION_MAP: Record<[AppConnection.CircleCI]: { name: "CircleCI", image: "CircleCI.png" },[AppConnection.AzureEntraId]: { name: "Azure Entra ID", image: "Microsoft Azure.png" },[AppConnection.Venafi]: { name: "Venafi TLS Protect Cloud", image: "Venafi.png" },+ [AppConnection.VenafiTpp]: { name: "Venafi TPP", image: "Venafi.png" },[AppConnection.ExternalInfisical]: { name: "Infisical", image: "Infisical.png" },[AppConnection.Doppler]: { name: "Doppler", image: "Doppler.png" },[AppConnection.NetScaler]: { name: "NetScaler", image: "NetScaler.png" },@@ -222,6 +224,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])case MySqlConnectionMethod.UsernameAndPassword:case OracleDBConnectionMethod.UsernameAndPassword:case AzureADCSConnectionMethod.UsernamePassword:+ case VenafiTppConnectionMethod.UsernamePassword:case RedisConnectionMethod.UsernameAndPassword:case MongoDBConnectionMethod.UsernameAndPassword:return { name: "Username & Password", icon: faLock };diff --git a/frontend/src/hooks/api/appConnections/enums.ts b/frontend/src/hooks/api/appConnections/enums.tsindex a7b25a7bed..149ac8a3c2 100644--- a/frontend/src/hooks/api/appConnections/enums.ts+++ b/frontend/src/hooks/api/appConnections/enums.ts@@ -52,6 +52,7 @@ export enum AppConnection {CircleCI = "circleci",AzureEntraId = "azure-entra-id",Venafi = "venafi",+ VenafiTpp = "venafi-tpp",ExternalInfisical = "external-infisical",Doppler = "doppler",NetScaler = "netscaler",diff --git a/frontend/src/hooks/api/appConnections/types/app-options.ts b/frontend/src/hooks/api/appConnections/types/app-options.tsindex c9f99789c7..6a56e5e3e6 100644--- a/frontend/src/hooks/api/appConnections/types/app-options.ts+++ b/frontend/src/hooks/api/appConnections/types/app-options.ts@@ -228,6 +228,10 @@ export type TVenafiConnectionOption = TAppConnectionOptionBase & {app: AppConnection.Venafi;};+export type TVenafiTppConnectionOption = TAppConnectionOptionBase & {+ app: AppConnection.VenafiTpp;+};+export type TExternalInfisicalConnectionOption = TAppConnectionOptionBase & {app: AppConnection.ExternalInfisical;};@@ -309,6 +313,7 @@ export type TAppConnectionOption =| TSmbConnectionOption| TAzureEntraIdConnectionOption| TVenafiConnectionOption+ | TVenafiTppConnectionOption| TExternalInfisicalConnectionOption| TDopplerConnectionOption| TNetScalerConnectionOption@@ -371,6 +376,7 @@ export type TAppConnectionOptionMap = {[AppConnection.CircleCI]: TCircleCISyncConnectionOption;[AppConnection.AzureEntraId]: TAzureEntraIdConnectionOption;[AppConnection.Venafi]: TVenafiConnectionOption;+ [AppConnection.VenafiTpp]: TVenafiTppConnectionOption;[AppConnection.ExternalInfisical]: TExternalInfisicalConnectionOption;[AppConnection.Doppler]: TDopplerConnectionOption;[AppConnection.NetScaler]: TNetScalerConnectionOption;diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.tsindex b8b880550f..e798d35b2f 100644--- a/frontend/src/hooks/api/appConnections/types/index.ts+++ b/frontend/src/hooks/api/appConnections/types/index.ts@@ -57,6 +57,7 @@ import { TTeamCityConnection } from "./teamcity-connection";import { TTerraformCloudConnection } from "./terraform-cloud-connection";import { TTravisCIConnection } from "./travis-ci-connection";import { TVenafiConnection } from "./venafi-connection";+import { TVenafiTppConnection } from "./venafi-tpp-connection";import { TVercelConnection } from "./vercel-connection";import { TWindmillConnection } from "./windmill-connection";import { TZabbixConnection } from "./zabbix-connection";@@ -116,6 +117,7 @@ export * from "./teamcity-connection";export * from "./terraform-cloud-connection";export * from "./travis-ci-connection";export * from "./venafi-connection";+export * from "./venafi-tpp-connection";export * from "./vercel-connection";export * from "./windmill-connection";export * from "./zabbix-connection";@@ -175,6 +177,7 @@ export type TAppConnection =| TCircleCIConnection| TAzureEntraIdConnection| TVenafiConnection+ | TVenafiTppConnection| TExternalInfisicalConnection| TNetScalerConnection| TDopplerConnectiondiff --git a/frontend/src/hooks/api/appConnections/types/venafi-tpp-connection.ts b/frontend/src/hooks/api/appConnections/types/venafi-tpp-connection.tsnew file mode 100644index 0000000000..0c3dd901cf--- /dev/null+++ b/frontend/src/hooks/api/appConnections/types/venafi-tpp-connection.ts@@ -0,0 +1,16 @@+import { AppConnection } from "../enums";+import { TRootAppConnection } from "./root-connection";++export enum VenafiTppConnectionMethod {+ UsernamePassword = "username-password"+}++export type TVenafiTppConnection = TRootAppConnection & {+ app: AppConnection.VenafiTpp;+ method: VenafiTppConnectionMethod.UsernamePassword;+ credentials: {+ tppUrl: string;+ clientId: string;+ username: string;+ };+};diff --git a/frontend/src/hooks/api/ca/constants.tsx b/frontend/src/hooks/api/ca/constants.tsxindex 979f9146e8..658d58f125 100644--- a/frontend/src/hooks/api/ca/constants.tsx+++ b/frontend/src/hooks/api/ca/constants.tsx@@ -54,7 +54,8 @@ export const CA_TYPE_CAPABILITIES_MAP: Record<CaType, CaCapability[]> = {CaCapability.ISSUE_CERTIFICATES,CaCapability.REVOKE_CERTIFICATES,CaCapability.RENEW_CERTIFICATES- ]+ ],+ [CaType.VENAFI_TPP]: [CaCapability.ISSUE_CERTIFICATES, CaCapability.RENEW_CERTIFICATES]};export const EXTERNAL_CA_TYPE_NAME_MAP: Record<string, string> = {@@ -62,7 +63,8 @@ export const EXTERNAL_CA_TYPE_NAME_MAP: Record<string, string> = {[CaType.AZURE_AD_CS]: "Active Directory Certificate Services (AD CS)",[CaType.AWS_PCA]: "AWS Private CA (PCA)",[CaType.DIGICERT]: "DigiCert CertCentral",- [CaType.AWS_ACM_PUBLIC_CA]: "AWS ACM Public CA"+ [CaType.AWS_ACM_PUBLIC_CA]: "AWS ACM Public CA",+ [CaType.VENAFI_TPP]: "Venafi TPP"};/**diff --git a/frontend/src/hooks/api/ca/enums.tsx b/frontend/src/hooks/api/ca/enums.tsxindex 7081c28198..00fa324896 100644--- a/frontend/src/hooks/api/ca/enums.tsx+++ b/frontend/src/hooks/api/ca/enums.tsx@@ -4,7 +4,8 @@ export enum CaType {AZURE_AD_CS = "azure-ad-cs",AWS_PCA = "aws-pca",DIGICERT = "digicert",- AWS_ACM_PUBLIC_CA = "aws-acm-public-ca"+ AWS_ACM_PUBLIC_CA = "aws-acm-public-ca",+ VENAFI_TPP = "venafi-tpp"}export enum InternalCaType {diff --git a/frontend/src/hooks/api/ca/queries.tsx b/frontend/src/hooks/api/ca/queries.tsxindex eaa82898cb..1cf31a0ad0 100644--- a/frontend/src/hooks/api/ca/queries.tsx+++ b/frontend/src/hooks/api/ca/queries.tsx@@ -86,8 +86,9 @@ export const useListExternalCasByProjectId = (projectId: string) => {acmeResponse,azureAdCsResponse,awsPcaResponse,+ digicertResponse,awsAcmPublicCaResponse,- digicertResponse+ venafiTppResponse] = await Promise.allSettled([apiRequest.get<TUnifiedCertificateAuthority[]>(`/api/v1/cert-manager/ca/${CaType.ACME}?projectId=${projectId}`@@ -103,6 +104,9 @@ export const useListExternalCasByProjectId = (projectId: string) => {),apiRequest.get<TUnifiedCertificateAuthority[]>(`/api/v1/cert-manager/ca/${CaType.AWS_ACM_PUBLIC_CA}?projectId=${projectId}`+ ),+ apiRequest.get<TUnifiedCertificateAuthority[]>(+ `/api/v1/cert-manager/ca/${CaType.VENAFI_TPP}?projectId=${projectId}`)]);@@ -128,6 +132,10 @@ export const useListExternalCasByProjectId = (projectId: string) => {allCas.push(...awsAcmPublicCaResponse.value.data);}+ if (venafiTppResponse.status === "fulfilled") {+ allCas.push(...venafiTppResponse.value.data);+ }+return allCas;}});diff --git a/frontend/src/hooks/api/ca/types.ts b/frontend/src/hooks/api/ca/types.tsindex 678e2c1baa..179db754fd 100644--- a/frontend/src/hooks/api/ca/types.ts+++ b/frontend/src/hooks/api/ca/types.ts@@ -78,6 +78,19 @@ export type TAwsAcmPublicCaCertificateAuthority = {};};+export type TVenafiTppCertificateAuthority = {+ id: string;+ projectId: string;+ type: CaType.VENAFI_TPP;+ status: CaStatus;+ name: string;+ enableDirectIssuance: boolean;+ configuration: {+ appConnectionId: string;+ policyDN: string;+ };+};+export type TInternalCertificateAuthority = {id: string;projectId: string;@@ -111,6 +124,7 @@ export type TUnifiedCertificateAuthority =| TAwsPcaCertificateAuthority| TDigiCertCertificateAuthority| TAwsAcmPublicCaCertificateAuthority+ | TVenafiTppCertificateAuthority| TInternalCertificateAuthority;export type TCreateCertificateAuthorityDTO = Omit<diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsxindex 256e053cf0..e41826288e 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaModal.tsx@@ -153,6 +153,14 @@ const awsAcmPublicCaConfigurationSchema = z.object({region: z.string().min(1, "Region is required")});+const venafiTppConfigurationSchema = z.object({+ venafiTppConnection: z.object({+ id: z.string().min(1, "Venafi TPP Connection is required"),+ name: z.string()+ }),+ policyDN: z.string().trim().min(1, "Policy DN is required")+});+const schema = z.discriminatedUnion("type", [baseSchema.extend({type: z.literal(CaType.ACME),@@ -173,6 +181,10 @@ const schema = z.discriminatedUnion("type", [baseSchema.extend({type: z.literal(CaType.AWS_ACM_PUBLIC_CA),configuration: awsAcmPublicCaConfigurationSchema+ }),+ baseSchema.extend({+ type: z.literal(CaType.VENAFI_TPP),+ configuration: venafiTppConfigurationSchema})]);@@ -188,7 +200,8 @@ const caTypes = [{ label: "Active Directory Certificate Services (AD CS)", value: CaType.AZURE_AD_CS },{ label: "AWS Private CA (PCA)", value: CaType.AWS_PCA },{ label: "AWS ACM Public CA", value: CaType.AWS_ACM_PUBLIC_CA },- { label: "DigiCert CertCentral", value: CaType.DIGICERT }+ { label: "DigiCert CertCentral", value: CaType.DIGICERT },+ { label: "Venafi TPP", value: CaType.VENAFI_TPP }];export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {@@ -284,6 +297,19 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {region: ""}});+ } else if (initialType === CaType.VENAFI_TPP) {+ reset({+ type: CaType.VENAFI_TPP,+ name: "",+ status: CaStatus.ACTIVE,+ configuration: {+ venafiTppConnection: {+ id: "",+ name: ""+ },+ policyDN: ""+ }+ });} else {reset({type: CaType.ACME,@@ -347,6 +373,11 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {enabled: caType === CaType.DIGICERT});+ const { data: availableVenafiTppConnections, isPending: isVenafiTppPending } =+ useListAvailableAppConnections(AppConnection.VenafiTpp, currentProject.id, {+ enabled: caType === CaType.VENAFI_TPP+ });+const availableConnections: TAvailableAppConnection[] = useMemo(() => {if (caType === CaType.AZURE_AD_CS) {return availableAzureConnections || [];@@ -357,6 +388,9 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {if (caType === CaType.DIGICERT) {return availableDigiCertConnections || [];}+ if (caType === CaType.VENAFI_TPP) {+ return availableVenafiTppConnections || [];+ }return [...(availableRoute53Connections || []),...(availableCloudflareConnections || []),@@ -371,7 +405,8 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {availableAzureDNSConnections,availableAzureConnections,availableAwsConnections,- availableDigiCertConnections+ availableDigiCertConnections,+ availableVenafiTppConnections]);const isPending =@@ -381,7 +416,8 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {isAzureDNSPending ||(isAzurePending && caType === CaType.AZURE_AD_CS) ||(isAwsPending && (caType === CaType.AWS_PCA || caType === CaType.AWS_ACM_PUBLIC_CA)) ||- (isDigiCertPending && caType === CaType.DIGICERT);+ (isDigiCertPending && caType === CaType.DIGICERT) ||+ (isVenafiTppPending && caType === CaType.VENAFI_TPP);const dnsAppConnection =caType === CaType.ACME && configuration && "dnsAppConnection" in configuration@@ -512,6 +548,23 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {region: ca.configuration.region}});+ } else if (ca.type === CaType.VENAFI_TPP && availableConnections?.length) {+ const selectedConnection = availableConnections?.find(+ (connection) => connection.id === ca.configuration.appConnectionId+ );++ reset({+ type: ca.type,+ name: ca.name,+ status: ca.status,+ configuration: {+ venafiTppConnection: {+ id: ca.configuration.appConnectionId,+ name: selectedConnection?.name || ""+ },+ policyDN: ca.configuration.policyDN+ }+ });}}}, [ca, availableConnections, reset, isCaLoading]);@@ -574,6 +627,11 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {hostedZoneId: formConfiguration.hostedZoneId,region: formConfiguration.region};+ } else if (type === CaType.VENAFI_TPP && "venafiTppConnection" in formConfiguration) {+ configPayload = {+ appConnectionId: formConfiguration.venafiTppConnection.id,+ policyDN: formConfiguration.policyDN+ };} else {throw new Error("Invalid certificate authority configuration");}@@ -1162,6 +1220,51 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {/></>)}+ {caType === CaType.VENAFI_TPP && (+ <>+ <Controller+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ tooltipText="Venafi TPP App Connection contains the credentials to connect to your Venafi Trust Protection Platform instance."+ isError={Boolean(error)}+ errorText={error?.message}+ label="Venafi TPP Connection"+ >+ <FilterableSelect+ value={value}+ onChange={(newValue) => {+ onChange(newValue);+ }}+ isLoading={isPending}+ options={availableConnections}+ placeholder="Select connection..."+ getOptionLabel={(option) => option.name}+ getOptionValue={(option) => option.id}+ components={{ Option: AppConnectionOption }}+ />+ </FormControl>+ )}+ control={control}+ name="configuration.venafiTppConnection"+ />+ <Controller+ control={control}+ defaultValue=""+ name="configuration.policyDN"+ render={({ field, fieldState: { error } }) => (+ <FormControl+ label="Policy DN"+ isError={Boolean(error)}+ errorText={error?.message}+ isRequired+ tooltipText="The policy folder path in Venafi TPP where certificates will be managed (e.g., \VED\Policy\Certificates)."+ >+ <Input {...field} placeholder="\VED\Policy\Certificates" />+ </FormControl>+ )}+ />+ </>+ )}<div className="flex items-center"><ButtonclassName="mr-4"diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsxindex 132619c32e..b4f6336347 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx@@ -71,6 +71,7 @@ import { TeamCityConnectionForm } from "./TeamCityConnectionForm";import { TerraformCloudConnectionForm } from "./TerraformCloudConnectionForm";import { TravisCIConnectionForm } from "./TravisCIConnectionForm";import { VenafiConnectionForm } from "./VenafiConnectionForm";+import { VenafiTppConnectionForm } from "./VenafiTppConnectionForm";import { VercelConnectionForm } from "./VercelConnectionForm";import { WindmillConnectionForm } from "./WindmillConnectionForm";import { ZabbixConnectionForm } from "./ZabbixConnectionForm";@@ -274,6 +275,8 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {return <CircleCIConnectionForm onSubmit={onSubmit} />;case AppConnection.Venafi:return <VenafiConnectionForm onSubmit={onSubmit} />;+ case AppConnection.VenafiTpp:+ return <VenafiTppConnectionForm onSubmit={onSubmit} />;case AppConnection.AzureEntraId:return <AzureEntraIdConnectionForm onSubmit={onSubmit} />;case AppConnection.ExternalInfisical:@@ -507,6 +510,10 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {return <DigiCertConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.TravisCI:return <TravisCIConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;+ case AppConnection.Venafi:+ return <VenafiConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;+ case AppConnection.VenafiTpp:+ return <VenafiTppConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;default:throw new Error(`Unhandled App ${(appConnection as TAppConnection).app}`);}diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/VenafiTppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/VenafiTppConnectionForm.tsxnew file mode 100644index 0000000000..52efb3cf6a--- /dev/null+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/VenafiTppConnectionForm.tsx@@ -0,0 +1,250 @@+import { Controller, FormProvider, useForm } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import { useQuery } from "@tanstack/react-query";+import { z } from "zod";++import { OrgPermissionCan } from "@app/components/permissions";+import {+ Button,+ FormControl,+ Input,+ ModalClose,+ SecretInput,+ Select,+ SelectItem,+ Tooltip+} from "@app/components/v2";+import { useSubscription } from "@app/context";+import {+ OrgGatewayPermissionActions,+ OrgPermissionSubjects+} from "@app/context/OrgPermissionContext/types";+import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";+import { gatewaysQueryKeys } from "@app/hooks/api";+import { TVenafiTppConnection, VenafiTppConnectionMethod } from "@app/hooks/api/appConnections";+import { AppConnection } from "@app/hooks/api/appConnections/enums";++import {+ genericAppConnectionFieldsSchema,+ GenericAppConnectionsFields+} from "./GenericAppConnectionFields";++type Props = {+ appConnection?: TVenafiTppConnection;+ onSubmit: (formData: FormData) => Promise<void>;+};++const rootSchema = genericAppConnectionFieldsSchema.extend({+ app: z.literal(AppConnection.VenafiTpp)+});++const formSchema = z.discriminatedUnion("method", [+ rootSchema.extend({+ method: z.literal(VenafiTppConnectionMethod.UsernamePassword),+ credentials: z.object({+ tppUrl: z+ .string()+ .trim()+ .min(1, "TPP URL required")+ .refine((value) => value.startsWith("https://"), "TPP URL must use HTTPS"),+ clientId: z.string().trim().min(1, "Client ID required"),+ username: z.string().trim().min(1, "Username required"),+ password: z.string().trim().min(1, "Password required")+ })+ })+]);++type FormData = z.infer<typeof formSchema>;++export const VenafiTppConnectionForm = ({ appConnection, onSubmit }: Props) => {+ const isUpdate = Boolean(appConnection);++ const form = useForm<FormData>({+ resolver: zodResolver(formSchema),+ defaultValues: appConnection ?? {+ app: AppConnection.VenafiTpp,+ method: VenafiTppConnectionMethod.UsernamePassword,+ name: "",+ description: "",+ gatewayId: null,+ credentials: {+ tppUrl: "",+ clientId: "",+ username: "",+ password: ""+ }+ }+ });++ const {+ handleSubmit,+ control,+ formState: { isSubmitting, isDirty }+ } = form;++ const { subscription } = useSubscription();+ const { data: gateways, isPending: isGatewaysLoading } = useQuery(gatewaysQueryKeys.list());++ return (+ <FormProvider {...form}>+ <form onSubmit={handleSubmit(onSubmit)}>+ {!isUpdate && <GenericAppConnectionsFields />}+ <Controller+ name="method"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ tooltipText={`The method you would like to use to connect with ${+ APP_CONNECTION_MAP[AppConnection.VenafiTpp].name+ }. This field cannot be changed after creation.`}+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Method"+ >+ <Select+ isDisabled={isUpdate}+ value={value}+ onValueChange={(val) => onChange(val)}+ className="w-full border border-mineshaft-500"+ position="popper"+ dropdownContainerClassName="max-w-none"+ >+ {Object.values(VenafiTppConnectionMethod).map((method) => {+ return (+ <SelectItem value={method} key={method}>+ {getAppConnectionMethodDetails(method).name}+ </SelectItem>+ );+ })}+ </Select>+ </FormControl>+ )}+ />+ {subscription.gateway && (+ <OrgPermissionCan+ I={OrgGatewayPermissionActions.AttachGateways}+ a={OrgPermissionSubjects.Gateway}+ >+ {(isAllowed) => (+ <Controller+ control={control}+ name="gatewayId"+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error?.message)}+ errorText={error?.message}+ label="Gateway"+ >+ <Tooltip+ isDisabled={isAllowed}+ content="Restricted access. You don't have permission to attach gateways to resources."+ >+ <Select+ isDisabled={!isAllowed}+ value={value as string}+ onValueChange={onChange}+ className="w-full border border-mineshaft-500"+ dropdownContainerClassName="max-w-none"+ isLoading={isGatewaysLoading}+ placeholder="Default: Internet Gateway"+ position="popper"+ >+ <SelectItem+ value={null as unknown as string}+ onClick={() => onChange(undefined)}+ >+ Internet Gateway+ </SelectItem>+ {gateways?.map((el) => (+ <SelectItem value={el.id} key={el.id}>+ {el.name}+ </SelectItem>+ ))}+ </Select>+ </Tooltip>+ </FormControl>+ )}+ />+ )}+ </OrgPermissionCan>+ )}+ <Controller+ name="credentials.tppUrl"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="TPP URL"+ >+ <Input {...field} placeholder="https://tpp.example.com" />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.clientId"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Client ID"+ tooltipText="The OAuth Client ID registered in the Venafi TPP API Integration."+ >+ <Input {...field} placeholder="my-infisical-integration" />+ </FormControl>+ )}+ />+ <div className="grid grid-cols-2 gap-2">+ <Controller+ name="credentials.username"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Username"+ >+ <Input {...field} placeholder="[email protected]" />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.password"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Password"+ >+ <SecretInput+ containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"+ value={value}+ onChange={(e) => onChange(e.target.value)}+ />+ </FormControl>+ )}+ />+ </div>+ <div className="mt-8 flex items-center">+ <Button+ className="mr-4"+ size="sm"+ type="submit"+ colorSchema="secondary"+ isLoading={isSubmitting}+ isDisabled={isSubmitting || !isDirty}+ >+ {isUpdate ? "Update Credentials" : "Connect to Venafi TPP"}+ </Button>+ <ModalClose asChild>+ <Button colorSchema="secondary" variant="plain">+ Cancel+ </Button>+ </ModalClose>+ </div>+ </form>+ </FormProvider>+ );+};