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
feat(pki-syncs): add Palo Alto Networks app connection and certificate syncs
Carlos Monastyrski968833d447c9
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 1e30189771..5012f35404 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@@ -196,6 +196,10 @@ import {} from "@app/services/app-connection/open-router";import { OpenAIConnectionListItemSchema, SanitizedOpenAIConnectionSchema } from "@app/services/app-connection/openai";import { OvhConnectionListItemSchema, SanitizedOvhConnectionSchema } from "@app/services/app-connection/ovh";+import {+ PaloAltoNetworksConnectionListItemSchema,+ SanitizedPaloAltoNetworksConnectionSchema+} from "@app/services/app-connection/palo-alto-networks";import {PostgresConnectionListItemSchema,SanitizedPostgresConnectionSchema@@ -342,6 +346,7 @@ const SanitizedAppConnectionSchema = z.union([...SanitizedVenafiTppConnectionSchema.options,...SanitizedExternalInfisicalConnectionSchema.options,...SanitizedNetScalerConnectionSchema.options,+ ...SanitizedPaloAltoNetworksConnectionSchema.options,...SanitizedKempLoadMasterConnectionSchema.options,...SanitizedDopplerConnectionSchema.options,...SanitizedOvhConnectionSchema.options,@@ -431,6 +436,7 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [ExternalInfisicalConnectionListItemSchema,DopplerConnectionListItemSchema,NetScalerConnectionListItemSchema,+ PaloAltoNetworksConnectionListItemSchema,KempLoadMasterConnectionListItemSchema,AnthropicConnectionListItemSchema,OvhConnectionListItemSchema,diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.tsindex 5622d8891f..a592fe7034 100644--- a/backend/src/server/routes/v1/app-connection-routers/index.ts+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts@@ -62,6 +62,7 @@ import { registerOnaConnectionRouter } from "./ona-connection-router";import { registerOpenRouterConnectionRouter } from "./open-router-connection-router";import { registerOpenAIConnectionRouter } from "./openai-connection-router";import { registerOvhConnectionRouter } from "./ovh-connection-router";+import { registerPaloAltoNetworksConnectionRouter } from "./palo-alto-networks-connection-router";import { registerPostgresConnectionRouter } from "./postgres-connection-router";import { registerPowerDnsConnectionRouter } from "./powerdns-connection-router";import { registerQoveryConnectionRouter } from "./qovery-connection-router";@@ -157,6 +158,7 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:[AppConnection.ExternalInfisical]: registerExternalInfisicalConnectionRouter,[AppConnection.Doppler]: registerDopplerConnectionRouter,[AppConnection.NetScaler]: registerNetScalerConnectionRouter,+ [AppConnection.PaloAltoNetworks]: registerPaloAltoNetworksConnectionRouter,[AppConnection.KempLoadMaster]: registerKempLoadMasterConnectionRouter,[AppConnection.Anthropic]: registerAnthropicConnectionRouter,[AppConnection.OVH]: registerOvhConnectionRouter,diff --git a/backend/src/server/routes/v1/app-connection-routers/palo-alto-networks-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/palo-alto-networks-connection-router.tsnew file mode 100644index 0000000000..bdf054e1cf--- /dev/null+++ b/backend/src/server/routes/v1/app-connection-routers/palo-alto-networks-connection-router.ts@@ -0,0 +1,80 @@+import z from "zod";++import { readLimit } from "@app/server/config/rateLimiter";+import { verifyAuth } from "@app/server/plugins/auth/verify-auth";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import {+ CreatePaloAltoNetworksConnectionSchema,+ SanitizedPaloAltoNetworksConnectionSchema,+ UpdatePaloAltoNetworksConnectionSchema+} from "@app/services/app-connection/palo-alto-networks";+import { PanOsObjectNameSchema } from "@app/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas";+import { AuthMode } from "@app/services/auth/auth-type";++import { registerAppConnectionEndpoints } from "./app-connection-endpoints";++export const registerPaloAltoNetworksConnectionRouter = async (server: FastifyZodProvider) => {+ registerAppConnectionEndpoints({+ app: AppConnection.PaloAltoNetworks,+ server,+ sanitizedResponseSchema: SanitizedPaloAltoNetworksConnectionSchema,+ createSchema: CreatePaloAltoNetworksConnectionSchema,+ updateSchema: UpdatePaloAltoNetworksConnectionSchema+ });++ server.route({+ method: "GET",+ url: `/:connectionId/templates`,+ config: {+ rateLimit: readLimit+ },+ schema: {+ operationId: "listPaloAltoNetworksTemplates",+ params: z.object({+ connectionId: z.string().uuid()+ }),+ response: {+ 200: z.object({+ isPanorama: z.boolean(),+ templates: z.string().array()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),+ handler: async (req) =>+ server.services.appConnection.paloAltoNetworks.listTemplates(+ { connectionId: req.params.connectionId },+ req.permission+ )+ });++ server.route({+ method: "GET",+ url: `/:connectionId/ssl-tls-service-profiles`,+ config: {+ rateLimit: readLimit+ },+ schema: {+ operationId: "listPaloAltoNetworksSslTlsServiceProfiles",+ params: z.object({+ connectionId: z.string().uuid()+ }),+ querystring: z.object({+ template: PanOsObjectNameSchema("Template").optional()+ }),+ response: {+ 200: z.object({+ sslTlsServiceProfiles: z.object({ name: z.string(), vsys: z.string().nullable() }).array()+ })+ }+ },+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.OAUTH]),+ handler: async (req) => {+ const sslTlsServiceProfiles = await server.services.appConnection.paloAltoNetworks.listSslTlsServiceProfiles(+ { connectionId: req.params.connectionId, template: req.query.template },+ req.permission+ );+ return { sslTlsServiceProfiles };+ }+ });+};diff --git a/backend/src/server/routes/v1/pki-sync-routers/index.ts b/backend/src/server/routes/v1/pki-sync-routers/index.tsindex 8ba0bc0f15..ab6b85fbe4 100644--- a/backend/src/server/routes/v1/pki-sync-routers/index.ts+++ b/backend/src/server/routes/v1/pki-sync-routers/index.ts@@ -12,6 +12,10 @@ import { registerKempLoadMasterPkiSyncRouter } from "./kemp-loadmaster-pki-sync-import { registerLinuxServerPkiSyncRouter } from "./linux-server-pki-sync-router";import { registerNetScalerPkiSyncRouter } from "./netscaler-pki-sync-router";import { registerNutanixPrismCentralPkiSyncRouter } from "./nutanix-prism-central-pki-sync-router";+import {+ registerPaloAltoNetworksPkiSyncRouter,+ registerPaloAltoNetworksSslTlsProfilePkiSyncRouter+} from "./palo-alto-networks-pki-sync-router";import { registerWindowsServerPkiSyncRouter } from "./windows-server-pki-sync-router";export * from "./pki-sync-router";@@ -28,6 +32,8 @@ export const PKI_SYNC_REGISTER_ROUTER_MAP: Record<[PkiSync.GcpCertificateManager]: registerGcpCertificateManagerPkiSyncRouter,[PkiSync.CloudflareCustomCertificate]: registerCloudflareCustomCertificatePkiSyncRouter,[PkiSync.NetScaler]: registerNetScalerPkiSyncRouter,+ [PkiSync.PaloAltoNetworks]: registerPaloAltoNetworksPkiSyncRouter,+ [PkiSync.PaloAltoNetworksSslTlsProfile]: registerPaloAltoNetworksSslTlsProfilePkiSyncRouter,[PkiSync.F5BigIp]: registerF5BigIpPkiSyncRouter,[PkiSync.KempLoadMaster]: registerKempLoadMasterPkiSyncRouter,[PkiSync.LinuxServer]: registerLinuxServerPkiSyncRouter,diff --git a/backend/src/server/routes/v1/pki-sync-routers/palo-alto-networks-pki-sync-router.ts b/backend/src/server/routes/v1/pki-sync-routers/palo-alto-networks-pki-sync-router.tsnew file mode 100644index 0000000000..2158cd55fd--- /dev/null+++ b/backend/src/server/routes/v1/pki-sync-routers/palo-alto-networks-pki-sync-router.ts@@ -0,0 +1,38 @@+import {+ PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION,+ PALO_ALTO_NETWORKS_SSL_TLS_PROFILE_PKI_SYNC_LIST_OPTION,+ PaloAltoNetworksPkiSyncSchemas,+ PaloAltoNetworksSslTlsProfilePkiSyncSchemas+} from "@app/services/pki-sync/palo-alto-networks";++import { registerSyncPkiEndpoints } from "./pki-sync-endpoints";++const registerRouter =+ (+ listOption:+ | typeof PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION+ | typeof PALO_ALTO_NETWORKS_SSL_TLS_PROFILE_PKI_SYNC_LIST_OPTION,+ schemas: typeof PaloAltoNetworksPkiSyncSchemas | typeof PaloAltoNetworksSslTlsProfilePkiSyncSchemas+ ) =>+ async (server: FastifyZodProvider, enableOperationId: boolean = true) =>+ registerSyncPkiEndpoints({+ destination: listOption.destination,+ server,+ ...schemas,+ syncOptions: {+ canImportCertificates: listOption.canImportCertificates,+ canRemoveCertificates: listOption.canRemoveCertificates,+ canRunHealthCheckCommand: listOption.canRunHealthCheckCommand+ },+ enableOperationId+ });++export const registerPaloAltoNetworksPkiSyncRouter = registerRouter(+ PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION,+ PaloAltoNetworksPkiSyncSchemas+);++export const registerPaloAltoNetworksSslTlsProfilePkiSyncRouter = registerRouter(+ PALO_ALTO_NETWORKS_SSL_TLS_PROFILE_PKI_SYNC_LIST_OPTION,+ PaloAltoNetworksSslTlsProfilePkiSyncSchemas+);diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.tsindex 837345b039..972e3b6606 100644--- a/backend/src/services/app-connection/app-connection-enums.ts+++ b/backend/src/services/app-connection/app-connection-enums.ts@@ -61,6 +61,7 @@ export enum AppConnection {ExternalInfisical = "external-infisical",Doppler = "doppler",NetScaler = "netscaler",+ PaloAltoNetworks = "palo-alto-networks",Anthropic = "anthropic",OVH = "ovh",Devin = "devin",diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.tsindex 6321a03075..052a61f345 100644--- a/backend/src/services/app-connection/app-connection-fns.ts+++ b/backend/src/services/app-connection/app-connection-fns.ts@@ -238,6 +238,11 @@ import {} from "./open-router";import { getOpenAIConnectionListItem, OpenAIConnectionMethod, validateOpenAIConnectionCredentials } from "./openai";import { getOvhConnectionListItem, OVHConnectionMethod, validateOvhConnectionCredentials } from "./ovh";+import {+ getPaloAltoNetworksConnectionListItem,+ PaloAltoNetworksConnectionMethod,+ validatePaloAltoNetworksConnectionCredentials+} from "./palo-alto-networks";import { getPostgresConnectionListItem, PostgresConnectionMethod } from "./postgres";import {getPowerDnsConnectionListItem,@@ -344,6 +349,7 @@ const PKI_APP_CONNECTIONS = [AppConnection.Venafi,AppConnection.VenafiTpp,AppConnection.NetScaler,+ AppConnection.PaloAltoNetworks,AppConnection.KempLoadMaster,AppConnection.DigiCert,AppConnection.F5BigIp,@@ -453,6 +459,7 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {getExternalInfisicalConnectionListItem(),getDopplerConnectionListItem(),getNetScalerConnectionListItem(),+ getPaloAltoNetworksConnectionListItem(),getKempLoadMasterConnectionListItem(),getOvhConnectionListItem(),getOnaConnectionListItem(),@@ -683,6 +690,8 @@ export const validateAppConnectionCredentials = async (gatewayV2Service)) as TAppConnectionCredentialsValidator,[AppConnection.NetScaler]: validateNetScalerConnectionCredentials as TAppConnectionCredentialsValidator,+ [AppConnection.PaloAltoNetworks]:+ validatePaloAltoNetworksConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.KempLoadMaster]: validateKempLoadMasterConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.Ona]: validateOnaConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.TravisCI]: validateTravisCIConnectionCredentials as TAppConnectionCredentialsValidator,@@ -829,6 +838,7 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>case SupabaseConnectionMethod.AccessToken:return "Access Token";case NetScalerConnectionMethod.BasicAuth:+ case PaloAltoNetworksConnectionMethod.BasicAuth:case KempLoadMasterConnectionMethod.BasicAuth:case F5BigIpConnectionMethod.BasicAuth:case NutanixPrismCentralConnectionMethod.BasicAuth:@@ -967,6 +977,7 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<[AppConnection.VenafiTpp]: platformManagedCredentialsNotSupported,[AppConnection.ExternalInfisical]: platformManagedCredentialsNotSupported,[AppConnection.NetScaler]: platformManagedCredentialsNotSupported,+ [AppConnection.PaloAltoNetworks]: platformManagedCredentialsNotSupported,[AppConnection.KempLoadMaster]: platformManagedCredentialsNotSupported,[AppConnection.Doppler]: platformManagedCredentialsNotSupported,[AppConnection.OVH]: platformManagedCredentialsNotSupported,diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.tsindex 47794df2b3..99a947ca72 100644--- a/backend/src/services/app-connection/app-connection-maps.ts+++ b/backend/src/services/app-connection/app-connection-maps.ts@@ -63,6 +63,7 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {[AppConnection.ExternalInfisical]: "Infisical",[AppConnection.Doppler]: "Doppler",[AppConnection.NetScaler]: "NetScaler",+ [AppConnection.PaloAltoNetworks]: "Palo Alto Networks",[AppConnection.KempLoadMaster]: "Kemp LoadMaster",[AppConnection.Anthropic]: "Anthropic",[AppConnection.OVH]: "OVH",@@ -153,6 +154,7 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp[AppConnection.ExternalInfisical]: AppConnectionPlanType.Regular,[AppConnection.Doppler]: AppConnectionPlanType.Regular,[AppConnection.NetScaler]: AppConnectionPlanType.Regular,+ [AppConnection.PaloAltoNetworks]: AppConnectionPlanType.Regular,[AppConnection.KempLoadMaster]: AppConnectionPlanType.Regular,[AppConnection.Anthropic]: AppConnectionPlanType.Regular,[AppConnection.OVH]: AppConnectionPlanType.Regular,diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.tsindex c4f1ebb923..4227d364e1 100644--- a/backend/src/services/app-connection/app-connection-service.ts+++ b/backend/src/services/app-connection/app-connection-service.ts@@ -167,6 +167,10 @@ import { ValidateOpenRouterConnectionCredentialsSchema } from "./open-router";import { ValidateOpenAIConnectionCredentialsSchema } from "./openai";import { openaiConnectionService } from "./openai/openai-connection-service";import { ValidateOvhConnectionCredentialsSchema } from "./ovh";+import {+ paloAltoNetworksConnectionService,+ ValidatePaloAltoNetworksConnectionCredentialsSchema+} from "./palo-alto-networks";import { ValidatePostgresConnectionCredentialsSchema } from "./postgres";import { powerDnsConnectionService, ValidatePowerDnsConnectionCredentialsSchema } from "./powerdns";import { ValidateQoveryConnectionCredentialsSchema } from "./qovery";@@ -300,6 +304,7 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp[AppConnection.ExternalInfisical]: ValidateExternalInfisicalConnectionCredentialsSchema,[AppConnection.Doppler]: ValidateDopplerConnectionCredentialsSchema,[AppConnection.NetScaler]: ValidateNetScalerConnectionCredentialsSchema,+ [AppConnection.PaloAltoNetworks]: ValidatePaloAltoNetworksConnectionCredentialsSchema,[AppConnection.KempLoadMaster]: ValidateKempLoadMasterConnectionCredentialsSchema,[AppConnection.Anthropic]: ValidateAnthropicConnectionCredentialsSchema,[AppConnection.OVH]: ValidateOvhConnectionCredentialsSchema,@@ -1499,6 +1504,7 @@ export const appConnectionServiceFactory = ({gatewayPoolService),powerDns: powerDnsConnectionService(connectAppConnectionById, gatewayV2Service, gatewayPoolService),+ paloAltoNetworks: paloAltoNetworksConnectionService(connectAppConnectionById, gatewayV2Service, gatewayPoolService),spacelift: spaceliftConnectionService(connectAppConnectionById)};};diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.tsindex 629a016ae3..148a464a75 100644--- a/backend/src/services/app-connection/app-connection-types.ts+++ b/backend/src/services/app-connection/app-connection-types.ts@@ -365,6 +365,12 @@ import {TOvhConnectionInput,TValidateOvhConnectionCredentialsSchema} from "./ovh";+import {+ TPaloAltoNetworksConnection,+ TPaloAltoNetworksConnectionConfig,+ TPaloAltoNetworksConnectionInput,+ TValidatePaloAltoNetworksConnectionCredentialsSchema+} from "./palo-alto-networks";import {TPostgresConnection,TPostgresConnectionInput,@@ -582,6 +588,7 @@ export type TAppConnection = { id: string; configuration?: TAppConnectionConfigu| TExternalInfisicalConnection| TDopplerConnection| TNetScalerConnection+ | TPaloAltoNetworksConnection| TKempLoadMasterConnection| TAnthropicConnection| TOvhConnection@@ -680,6 +687,7 @@ export type TAppConnectionInput = { id: string } & (| TExternalInfisicalConnectionInput| TDopplerConnectionInput| TNetScalerConnectionInput+ | TPaloAltoNetworksConnectionInput| TKempLoadMasterConnectionInput| TAnthropicConnectionInput| TOvhConnectionInput@@ -812,6 +820,7 @@ export type TAppConnectionConfig =| TExternalInfisicalConnectionConfig| TDopplerConnectionConfig| TNetScalerConnectionConfig+ | TPaloAltoNetworksConnectionConfig| TKempLoadMasterConnectionConfig| TAnthropicConnectionConfig| TOvhConnectionConfig@@ -901,6 +910,7 @@ export type TValidateAppConnectionCredentialsSchema =| TValidateExternalInfisicalConnectionCredentialsSchema| TValidateDopplerConnectionCredentialsSchema| TValidateNetScalerConnectionCredentialsSchema+ | TValidatePaloAltoNetworksConnectionCredentialsSchema| TValidateKempLoadMasterConnectionCredentialsSchema| TValidateAnthropicConnectionCredentialsSchema| TValidateOvhConnectionCredentialsSchemadiff --git a/backend/src/services/app-connection/palo-alto-networks/index.ts b/backend/src/services/app-connection/palo-alto-networks/index.tsnew file mode 100644index 0000000000..db0396c249--- /dev/null+++ b/backend/src/services/app-connection/palo-alto-networks/index.ts@@ -0,0 +1,19 @@+export { PaloAltoNetworksConnectionMethod } from "./palo-alto-networks-connection-enums";+export {+ getPaloAltoNetworksConnectionListItem,+ validatePaloAltoNetworksConnectionCredentials+} from "./palo-alto-networks-connection-fns";+export {+ CreatePaloAltoNetworksConnectionSchema,+ PaloAltoNetworksConnectionListItemSchema,+ SanitizedPaloAltoNetworksConnectionSchema,+ UpdatePaloAltoNetworksConnectionSchema,+ ValidatePaloAltoNetworksConnectionCredentialsSchema+} from "./palo-alto-networks-connection-schemas";+export { paloAltoNetworksConnectionService } from "./palo-alto-networks-connection-service";+export type {+ TPaloAltoNetworksConnection,+ TPaloAltoNetworksConnectionConfig,+ TPaloAltoNetworksConnectionInput,+ TValidatePaloAltoNetworksConnectionCredentialsSchema+} from "./palo-alto-networks-connection-types";diff --git a/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-enums.ts b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-enums.tsnew file mode 100644index 0000000000..c849091109--- /dev/null+++ b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-enums.ts@@ -0,0 +1,3 @@+export enum PaloAltoNetworksConnectionMethod {+ BasicAuth = "basic-auth"+}diff --git a/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-fns.ts b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-fns.tsnew file mode 100644index 0000000000..3965c3ccce--- /dev/null+++ b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-fns.ts@@ -0,0 +1,383 @@+/* eslint-disable no-await-in-loop */+import { AxiosError, AxiosRequestConfig } from "axios";+import { XMLParser } from "fast-xml-parser";+import RE2 from "re2";++import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";+import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";+import { getConfig } from "@app/lib/config/env";+import { request } from "@app/lib/config/request";+import { delay } from "@app/lib/delay";+import { BadRequestError, GatewayTransportError } from "@app/lib/errors";+import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";+import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";+import { GatewayProxyProtocol } from "@app/lib/gateway-v2/types";+import { RETRYABLE_NETWORK_ERRORS } from "@app/lib/retry/network-errors";+import { blockLocalAndPrivateIpAddresses, safeRequest } from "@app/lib/validator";+import { getSharedHttpsAgent } from "@app/lib/validator/safe-request";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++import { PaloAltoNetworksConnectionMethod } from "./palo-alto-networks-connection-enums";+import { TPaloAltoNetworksConnection, TPaloAltoNetworksConnectionConfig } from "./palo-alto-networks-connection-types";++const PAN_OS_DEFAULT_PORT = 443;+const PAN_OS_REQUEST_TIMEOUT_MS = 60_000;+const PAN_OS_JOB_POLL_INTERVAL_MS = 3_000;+const PAN_OS_JOB_TIMEOUT_MS = 15 * 60_000;+const NO_CHANGES_PATTERN = new RE2("no changes to commit", "i");+const JOB_ID_PATTERN = new RE2("^\\d+$");++export const PAN_OS_LOCALHOST_ENTRY = "entry[@name='localhost.localdomain']";++type TPaloAltoNetworksCredentials = TPaloAltoNetworksConnection["credentials"];++type TRequestFn = <R>(requestCfg: AxiosRequestConfig) => Promise<R>;++const panOsXmlParser = new XMLParser({+ ignoreAttributes: false,+ attributeNamePrefix: "@_",+ parseTagValue: false,+ isArray: (tagName) => ["entry", "member", "line"].includes(tagName)+});++type TPanOsXmlNode = Record<string, unknown>;++type TPanOsResponse = {+ "@_status"?: string;+ "@_code"?: string;+ result?: TPanOsXmlNode;+ msg?: unknown;+};++type TPanOsJob = {+ status: string;+ result: string;+ details: string[];+ devices: Array<{ name: string; result: string; details: string[] }>;+};++export class PanOsApiError extends Error {+ constructor(message: string) {+ super(message);+ this.name = "PanOsApiError";+ }+}++const collectText = (node: unknown): string[] => {+ if (node === undefined || node === null) return [];+ if (typeof node === "string" || typeof node === "number") return [String(node).trim()].filter(Boolean);+ if (Array.isArray(node)) return node.flatMap(collectText);+ if (typeof node === "object") {+ return Object.entries(node)+ .filter(([key]) => !key.startsWith("@_"))+ .flatMap(([, value]) => collectText(value));+ }+ return [];+};++const parsePanOsResponse = (xml: string): TPanOsResponse => {+ const parsed = panOsXmlParser.parse(xml) as { response?: TPanOsResponse };+ if (!parsed?.response) {+ throw new PanOsApiError(+ "Received an unexpected response from PAN-OS. Verify the hostname and port point to the management interface."+ );+ }+ return parsed.response;+};++export const getEntries = (node: unknown): TPanOsXmlNode[] =>+ (node as { entry?: TPanOsXmlNode[] } | undefined)?.entry ?? [];++const getResponseMessage = (response: TPanOsResponse) =>+ collectText(response.msg ?? (response.result as TPanOsXmlNode | undefined)?.msg ?? response.result).join(" ");++export const getPaloAltoNetworksConnectionListItem = () => {+ return {+ name: "Palo Alto Networks" as const,+ app: AppConnection.PaloAltoNetworks as const,+ methods: Object.values(PaloAltoNetworksConnectionMethod) as [PaloAltoNetworksConnectionMethod.BasicAuth]+ };+};++const executePaloAltoNetworksOperationWithGateway = async <T>(+ config: {+ gatewayId?: string | null;+ credentials: TPaloAltoNetworksCredentials;+ },+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId"> | undefined,+ operation: (makeRequest: TRequestFn) => Promise<T>+): Promise<T> => {+ const { gatewayId, credentials } = config;+ const { hostname } = credentials;+ const port = credentials.port ?? PAN_OS_DEFAULT_PORT;++ if (gatewayId) {+ if (!gatewayV2Service) {+ throw new BadRequestError({ message: getMissingGatewayMessage(gatewayId) });+ }++ await blockLocalAndPrivateIpAddresses(`https://${hostname}`, true);++ const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({+ gatewayId,+ targetHost: hostname,+ targetPort: port+ });++ if (!platformConnectionDetails) {+ throw new BadRequestError({ message: getMissingGatewayMessage(gatewayId) });+ }++ return withGatewayV2Proxy(+ async (proxyPort) => {+ const httpsAgent = getSharedHttpsAgent({+ servername: hostname,+ ca: credentials.sslCertificate,+ rejectUnauthorized: credentials.sslRejectUnauthorized ?? true+ });++ return operation(async <R>(requestCfg: AxiosRequestConfig) => {+ const resp = await request.request<R>({+ ...requestCfg,+ url: `https://localhost:${proxyPort}${requestCfg.url}`,+ headers: { ...requestCfg.headers, Host: hostname },+ httpsAgent,+ maxRedirects: 0+ });+ return resp.data;+ });+ },+ {+ protocol: GatewayProxyProtocol.Tcp,+ ...platformConnectionDetails+ }+ );+ }++ return operation(async <R>(requestCfg: AxiosRequestConfig) => {+ const resp = await safeRequest.request<R>({+ ...requestCfg,+ url: `https://${hostname}:${port}${requestCfg.url}`,+ ca: credentials.sslCertificate,+ rejectUnauthorized: credentials.sslRejectUnauthorized,+ servername: hostname,+ allowPrivateIps: getConfig().ALLOW_INTERNAL_IP_CONNECTIONS+ });+ return resp.data;+ });+};++const createPanOsClient = async (credentials: TPaloAltoNetworksCredentials, makeRequest: TRequestFn) => {+ const send = async (data: URLSearchParams | FormData, headers: Record<string, string>, query?: URLSearchParams) => {+ let xml: string;+ try {+ xml = await makeRequest<string>({+ method: "POST",+ url: query ? `/api/?${query.toString()}` : "/api/",+ data,+ headers,+ responseType: "text",+ timeout: PAN_OS_REQUEST_TIMEOUT_MS+ });+ } catch (error) {+ if (error instanceof AxiosError && typeof error.response?.data === "string" && error.response.data) {+ xml = error.response.data;+ } else {+ throw error;+ }+ }++ const response = parsePanOsResponse(xml);+ if (response["@_status"] !== "success") {+ throw new PanOsApiError(getResponseMessage(response) || "PAN-OS rejected the request");+ }+ return response;+ };++ const keygenResponse = await send(+ new URLSearchParams({ type: "keygen", user: credentials.username, password: credentials.password }),+ { "Content-Type": "application/x-www-form-urlencoded" }+ );+ const apiKey = collectText((keygenResponse.result as { key?: unknown } | undefined)?.key)[0];+ if (!apiKey) {+ throw new PanOsApiError("PAN-OS did not return an API key for these credentials");+ }++ const call = (params: Record<string, string>) =>+ send(new URLSearchParams(params), {+ "Content-Type": "application/x-www-form-urlencoded",+ "X-PAN-KEY": apiKey+ });++ const op = async (cmd: string) => (await call({ type: "op", cmd })).result ?? {};++ const getConfigNode = async (xpath: string) => (await call({ type: "config", action: "get", xpath })).result ?? {};++ const parseJob = (node: unknown): TPanOsJob => {+ const job = ((node as { job?: TPanOsXmlNode[] | TPanOsXmlNode })?.job ?? {}) as TPanOsXmlNode;+ const jobNode = (Array.isArray(job) ? job[0] : job) as TPanOsXmlNode;+ const deviceEntries = getEntries(jobNode.devices).map((entry) => ({+ name: String(entry.devicename ?? entry["serial-no"] ?? entry["@_name"] ?? "unknown"),+ result: String(entry.result ?? ""),+ details: collectText(entry.details)+ }));+ return {+ status: String(jobNode.status ?? ""),+ result: String(jobNode.result ?? ""),+ details: collectText(jobNode.details),+ devices: deviceEntries+ };+ };++ const waitForJob = async (jobId: string): Promise<TPanOsJob> => {+ const deadline = Date.now() + PAN_OS_JOB_TIMEOUT_MS;+ while (Date.now() < deadline) {+ const job = parseJob(await op(`<show><jobs><id>${jobId}</id></jobs></show>`));+ if (job.status === "FIN" && !job.devices.some((device) => device.result === "PEND")) {+ return job;+ }+ await delay(PAN_OS_JOB_POLL_INTERVAL_MS);+ }+ throw new PanOsApiError(`PAN-OS job ${jobId} did not finish within ${PAN_OS_JOB_TIMEOUT_MS / 60_000} minutes`);+ };++ const startCommit = async (params: Record<string, string>): Promise<string | undefined> => {+ const response = await call({ type: "commit", ...params });+ const jobId = collectText((response.result as { job?: unknown } | undefined)?.job)[0];+ if (jobId && JOB_ID_PATTERN.test(jobId)) return jobId;+ if (NO_CHANGES_PATTERN.test(getResponseMessage(response))) return undefined;+ throw new PanOsApiError(`PAN-OS did not return a commit job: ${getResponseMessage(response)}`);+ };++ return {+ username: credentials.username,+ op,+ getConfig: getConfigNode,+ editConfig: (xpath: string, element: string) => call({ type: "config", action: "edit", xpath, element }),+ deleteConfig: (xpath: string) => call({ type: "config", action: "delete", xpath }),+ importFile: (params: Record<string, string>, fileName: string, content: string) => {+ const form = new FormData();+ form.append("file", new Blob([content], { type: "application/x-pem-file" }), fileName);+ return send(form, { "X-PAN-KEY": apiKey }, new URLSearchParams(params));+ },+ startCommit,+ waitForJob+ };+};++export type TPanOsClient = Awaited<ReturnType<typeof createPanOsClient>>;++export const isPanorama = async (client: TPanOsClient) => {+ const result = await client.op("<show><system><info></info></system></show>");+ const model = collectText((result.system as TPanOsXmlNode | undefined)?.model)[0] ?? "";+ return model === "Panorama" || model.startsWith("M-");+};++const getEntryNames = (node: unknown): string[] =>+ getEntries(node)+ .map((entry) => String(entry["@_name"] ?? ""))+ .filter(Boolean);++export const listPanoramaTemplates = async (client: TPanOsClient) => {+ const result = await client.getConfig(`/config/devices/${PAN_OS_LOCALHOST_ENTRY}/template`);+ return getEntryNames(result.template);+};++export const getConfigRoot = (template?: string) =>+ template ? `/config/devices/${PAN_OS_LOCALHOST_ENTRY}/template/entry[@name='${template}']/config` : "/config";++export const listSslTlsServiceProfiles = async (client: TPanOsClient, template?: string) => {+ const root = getConfigRoot(template);+ const [sharedResult, vsysResult] = await Promise.all([+ client.getConfig(`${root}/shared/ssl-tls-service-profile`),+ client.getConfig(`${root}/devices/${PAN_OS_LOCALHOST_ENTRY}/vsys`)+ ]);++ const profiles: Array<{ name: string; vsys: string | null }> = getEntryNames(+ sharedResult["ssl-tls-service-profile"]+ ).map((name) => ({ name, vsys: null }));++ getEntries(vsysResult.vsys).forEach((vsys) => {+ getEntryNames(vsys["ssl-tls-service-profile"]).forEach((name) =>+ profiles.push({ name, vsys: String(vsys["@_name"]) })+ );+ });++ return profiles;+};++const UNTRUSTED_TLS_CODES = new Set([+ "DEPTH_ZERO_SELF_SIGNED_CERT",+ "SELF_SIGNED_CERT_IN_CHAIN",+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",+ "CERT_HAS_EXPIRED",+ "ERR_TLS_CERT_ALTNAME_INVALID"+]);++const UNTRUSTED_TLS_PATTERN = new RE2(+ "self[- ]signed certificate|unable to verify the first certificate|unable to get local issuer|certificate has expired|altnames",+ "i"+);+const GATEWAY_TRANSPORT_PATTERN = new RE2("gateway mTLS", "i");+const UNREACHABLE_PATTERN = new RE2(+ [...RETRYABLE_NETWORK_ERRORS, "socket disconnected before secure TLS connection", "socket hang up"].join("|"),+ "i"+);++export const describePanOsError = (error: unknown) => {+ if (error instanceof PanOsApiError) return error.message;+ const code = (error as { code?: string })?.code;+ const detail = error instanceof Error ? error.message : "Unknown error";+ if (error instanceof GatewayTransportError || GATEWAY_TRANSPORT_PATTERN.test(detail)) {+ return "the gateway could not be reached. Check that the gateway is running and connected to its relay.";+ }+ if ((code && UNTRUSTED_TLS_CODES.has(code)) || UNTRUSTED_TLS_PATTERN.test(detail)) {+ return `the management interface's TLS certificate is not trusted (${detail}). Add its CA certificate in the connection's SSL settings, or turn off Reject Unauthorized.`;+ }+ if (code === "ECONNABORTED") return "the request to PAN-OS timed out";+ if (UNREACHABLE_PATTERN.test(`${code ?? ""} ${detail}`)) {+ return `the management interface could not be reached (${detail}). Check the hostname and port, and that HTTPS management access is allowed from Infisical or the gateway.`;+ }+ return detail;+};++export const withPanOsClient = async <T>(+ connection: Pick<TPaloAltoNetworksConnection, "credentials" | "gatewayId" | "gatewayPoolId">,+ {+ gatewayV2Service,+ gatewayPoolService+ }: {+ gatewayV2Service?: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;+ gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;+ },+ operation: (client: TPanOsClient) => Promise<T>+): Promise<T> => {+ const gatewayId = gatewayPoolService+ ? await gatewayPoolService.resolveEffectiveGatewayId({+ gatewayId: connection.gatewayId,+ gatewayPoolId: connection.gatewayPoolId+ })+ : (connection.gatewayId ?? null);++ return executePaloAltoNetworksOperationWithGateway(+ { gatewayId, credentials: connection.credentials },+ gatewayV2Service,+ async (makeRequest) => operation(await createPanOsClient(connection.credentials, makeRequest))+ );+};++export const validatePaloAltoNetworksConnectionCredentials = async (+ config: TPaloAltoNetworksConnectionConfig,+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">+) => {+ try {+ await withPanOsClient(config, { gatewayV2Service }, isPanorama);+ } catch (error: unknown) {+ throw new BadRequestError({+ message: `Unable to validate connection: ${describePanOsError(error)}`+ });+ }++ return config.credentials;+};diff --git a/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas.ts b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas.tsnew file mode 100644index 0000000000..1e0c0bcb9b--- /dev/null+++ b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas.ts@@ -0,0 +1,103 @@+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 { PaloAltoNetworksConnectionMethod } from "./palo-alto-networks-connection-enums";++export const PaloAltoNetworksConnectionBasicAuthCredentialsSchema = z.object({+ hostname: z+ .string()+ .trim()+ .min(1, "Hostname is required")+ .max(512, "Hostname cannot exceed 512 characters")+ .refine((val) => !val.includes("/") && !val.includes("@") && !val.includes("?"), {+ message: "Hostname must not contain /, @, or ? characters"+ }),+ port: z.number().int().min(1).max(65535).optional(),+ username: z.string().trim().min(1, "Username is required").max(256, "Username cannot exceed 256 characters"),+ password: z.string().min(1, "Password is required").max(512, "Password cannot exceed 512 characters"),+ sslRejectUnauthorized: z.boolean().optional(),+ sslCertificate: z+ .string()+ .trim()+ .max(16384, "SSL certificate cannot exceed 16384 characters")+ .transform((value) => value || undefined)+ .optional()+});++const BasePaloAltoNetworksConnectionSchema = BaseAppConnectionSchema.extend({+ app: z.literal(AppConnection.PaloAltoNetworks)+});++export const PaloAltoNetworksConnectionSchema = BasePaloAltoNetworksConnectionSchema.extend({+ method: z.literal(PaloAltoNetworksConnectionMethod.BasicAuth),+ credentials: PaloAltoNetworksConnectionBasicAuthCredentialsSchema+});++export const SanitizedPaloAltoNetworksConnectionSchema = z.discriminatedUnion("method", [+ BasePaloAltoNetworksConnectionSchema.extend({+ method: z.literal(PaloAltoNetworksConnectionMethod.BasicAuth),+ credentials: PaloAltoNetworksConnectionBasicAuthCredentialsSchema.pick({+ hostname: true,+ port: true,+ username: true,+ sslRejectUnauthorized: true,+ sslCertificate: true+ })+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.PaloAltoNetworks]} (Basic Auth)` }))+]);++export const ValidatePaloAltoNetworksConnectionCredentialsSchema = z.discriminatedUnion("method", [+ z.object({+ method: z+ .literal(PaloAltoNetworksConnectionMethod.BasicAuth)+ .describe(AppConnections.CREATE(AppConnection.PaloAltoNetworks).method),+ credentials: PaloAltoNetworksConnectionBasicAuthCredentialsSchema.describe(+ AppConnections.CREATE(AppConnection.PaloAltoNetworks).credentials+ )+ })+]);++export const CreatePaloAltoNetworksConnectionSchema = ValidatePaloAltoNetworksConnectionCredentialsSchema.and(+ GenericCreateAppConnectionFieldsSchema(AppConnection.PaloAltoNetworks, {+ supportsGateways: true+ })+);++export const UpdatePaloAltoNetworksConnectionSchema = z+ .object({+ credentials: PaloAltoNetworksConnectionBasicAuthCredentialsSchema.optional().describe(+ AppConnections.UPDATE(AppConnection.PaloAltoNetworks).credentials+ )+ })+ .and(+ GenericUpdateAppConnectionFieldsSchema(AppConnection.PaloAltoNetworks, {+ supportsGateways: true+ })+ );++export const PaloAltoNetworksConnectionListItemSchema = z+ .object({+ name: z.literal("Palo Alto Networks"),+ app: z.literal(AppConnection.PaloAltoNetworks),+ methods: z.nativeEnum(PaloAltoNetworksConnectionMethod).array()+ })+ .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.PaloAltoNetworks] }));++export const PanOsObjectNameSchema = (field: string) =>+ z+ .string()+ .trim()+ .min(1, `${field} is required`)+ .max(63, `${field} cannot exceed 63 characters`)+ .regex(+ /^[A-Za-z0-9 ._-]+$/,+ `${field} can only contain letters, numbers, spaces, periods, hyphens, and underscores`+ );diff --git a/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-service.ts b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-service.tsnew file mode 100644index 0000000000..97100b1742--- /dev/null+++ b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-service.ts@@ -0,0 +1,59 @@+import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";+import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";+import { BadRequestError } from "@app/lib/errors";+import { OrgServiceActor } from "@app/lib/types";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++import {+ describePanOsError,+ isPanorama,+ listPanoramaTemplates,+ listSslTlsServiceProfiles,+ TPanOsClient,+ withPanOsClient+} from "./palo-alto-networks-connection-fns";+import { TPaloAltoNetworksConnection } from "./palo-alto-networks-connection-types";++type TGetAppConnectionFunc = (+ app: AppConnection,+ connectionId: string,+ actor: OrgServiceActor+) => Promise<TPaloAltoNetworksConnection>;++export const paloAltoNetworksConnectionService = (+ getAppConnection: TGetAppConnectionFunc,+ gatewayV2Service?: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,+ gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">+) => {+ const withClient = async <T>(+ connectionId: string,+ actor: OrgServiceActor,+ resourceLabel: string,+ operation: (client: TPanOsClient) => Promise<T>+ ): Promise<T> => {+ const appConnection = await getAppConnection(AppConnection.PaloAltoNetworks, connectionId, actor);+ try {+ return await withPanOsClient(appConnection, { gatewayV2Service, gatewayPoolService }, operation);+ } catch (error) {+ throw new BadRequestError({+ message: `Failed to list ${resourceLabel} for Palo Alto Networks connection '${appConnection.name}': ${describePanOsError(error)}`+ });+ }+ };++ const listTemplates = async ({ connectionId }: { connectionId: string }, actor: OrgServiceActor) =>+ withClient(connectionId, actor, "templates", async (client) => {+ if (!(await isPanorama(client))) return { isPanorama: false, templates: [] };+ return { isPanorama: true, templates: await listPanoramaTemplates(client) };+ });++ const listProfiles = async (+ { connectionId, template }: { connectionId: string; template?: string },+ actor: OrgServiceActor+ ) =>+ withClient(connectionId, actor, "SSL/TLS service profiles", (client) =>+ listSslTlsServiceProfiles(client, template)+ );++ return { listTemplates, listSslTlsServiceProfiles: listProfiles };+};diff --git a/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-types.ts b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-types.tsnew file mode 100644index 0000000000..8fc8d1566c--- /dev/null+++ b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-types.ts@@ -0,0 +1,26 @@+import z from "zod";++import { DiscriminativePick } from "@app/lib/types";++import { AppConnection } from "../app-connection-enums";+import {+ CreatePaloAltoNetworksConnectionSchema,+ PaloAltoNetworksConnectionSchema,+ ValidatePaloAltoNetworksConnectionCredentialsSchema+} from "./palo-alto-networks-connection-schemas";++export type TPaloAltoNetworksConnection = z.infer<typeof PaloAltoNetworksConnectionSchema>;++export type TPaloAltoNetworksConnectionInput = z.infer<typeof CreatePaloAltoNetworksConnectionSchema> & {+ app: AppConnection.PaloAltoNetworks;+};++export type TValidatePaloAltoNetworksConnectionCredentialsSchema =+ typeof ValidatePaloAltoNetworksConnectionCredentialsSchema;++export type TPaloAltoNetworksConnectionConfig = DiscriminativePick<+ TPaloAltoNetworksConnectionInput,+ "method" | "app" | "credentials" | "gatewayId" | "gatewayPoolId"+> & {+ orgId: string;+};diff --git a/backend/src/services/certificate-sync/certificate-sync-dal.ts b/backend/src/services/certificate-sync/certificate-sync-dal.tsindex 1a48dd6c27..4318bf6f3d 100644--- a/backend/src/services/certificate-sync/certificate-sync-dal.ts+++ b/backend/src/services/certificate-sync/certificate-sync-dal.ts@@ -72,15 +72,16 @@ export const certificateSyncDALFactory = (db: TDbClient) => {const findExternalIdentifiersInUse = async (externalIdentifiers: string[],- { excludePkiSyncId, destination }: { excludePkiSyncId: string; destination: string },+ { excludePkiSyncId, destination }: { excludePkiSyncId: string; destination: string | string[] },tx?: Knex): Promise<Set<string>> => {try {if (externalIdentifiers.length === 0) return new Set();+ const destinations = Array.isArray(destination) ? destination : [destination];const docs = (await (tx || db)(TableName.CertificateSync).join(TableName.PkiSync, `${TableName.PkiSync}.id`, `${TableName.CertificateSync}.pkiSyncId`).whereIn(`${TableName.CertificateSync}.externalIdentifier`, externalIdentifiers)- .where(`${TableName.PkiSync}.destination`, destination)+ .whereIn(`${TableName.PkiSync}.destination`, destinations).whereNot(`${TableName.CertificateSync}.pkiSyncId`, excludePkiSyncId).select(`${TableName.CertificateSync}.externalIdentifier`)) as Array<{ externalIdentifier: string | null }>;return new Set(docs.map((doc) => doc.externalIdentifier).filter((v): v is string => Boolean(v)));@@ -201,6 +202,27 @@ export const certificateSyncDALFactory = (db: TDbClient) => {}};+ const updateSyncStatusIfIn = async (+ {+ pkiSyncId,+ certificateIds,+ currentStatuses,+ status,+ message+ }: { pkiSyncId: string; certificateIds: string[]; currentStatuses: string[]; status: string; message: string },+ tx?: Knex+ ): Promise<void> => {+ try {+ await (tx || db)(TableName.CertificateSync)+ .where({ pkiSyncId })+ .whereIn("certificateId", certificateIds)+ .whereIn("syncStatus", currentStatuses)+ .update({ syncStatus: status, lastSyncMessage: message, lastSyncedAt: new Date() });+ } catch (error) {+ throw new DatabaseError({ error, name: "UpdateSyncStatusIfIn" });+ }+ };+const updateSyncMetadata = async (pkiSyncId: string,certificateId: string,@@ -231,10 +253,16 @@ export const certificateSyncDALFactory = (db: TDbClient) => {* 2. Removes the flag from the JSONB object using the `-` operator* 3. If removing the flag results in an empty object `{}`, sets the column to NULL instead*/- const clearSyncMetadataFlag = async (pkiSyncId: string, flag: string, tx?: Knex): Promise<void> => {+ const clearSyncMetadataFlag = async (+ pkiSyncId: string,+ flag: string,+ tx?: Knex,+ certificateIds?: string[]+ ): Promise<void> => {try {- await (tx || db)(TableName.CertificateSync)- .where({ pkiSyncId })+ const query = (tx || db)(TableName.CertificateSync).where({ pkiSyncId });+ if (certificateIds) void query.whereIn("certificateId", certificateIds);+ await query.whereNotNull("syncMetadata").whereRaw(`"syncMetadata" \\? ?`, [flag]).update({@@ -248,6 +276,23 @@ export const certificateSyncDALFactory = (db: TDbClient) => {}};+ const setSyncMetadataFlag = async (+ pkiSyncId: string,+ flag: string,+ certificateIds?: string[],+ tx?: Knex+ ): Promise<void> => {+ try {+ const query = (tx || db)(TableName.CertificateSync).where({ pkiSyncId });+ if (certificateIds) void query.whereIn("certificateId", certificateIds);+ await query.update({+ syncMetadata: db.raw(`COALESCE("syncMetadata", '{}'::jsonb) || jsonb_build_object(?::text, true)`, [flag])+ });+ } catch (error) {+ throw new DatabaseError({ error, name: "SetSyncMetadataFlag" });+ }+ };+const findWithDetails = async (options: {filter?: CertificateSyncFindFilter;@@ -358,6 +403,8 @@ export const certificateSyncDALFactory = (db: TDbClient) => {bulkUpdateSyncStatus,updateSyncMetadata,clearSyncMetadataFlag,+ setSyncMetadataFlag,+ updateSyncStatusIfIn,findWithDetails};};diff --git a/backend/src/services/pki-sync/palo-alto-networks/index.ts b/backend/src/services/pki-sync/palo-alto-networks/index.tsnew file mode 100644index 0000000000..9fbc5a9a78--- /dev/null+++ b/backend/src/services/pki-sync/palo-alto-networks/index.ts@@ -0,0 +1,4 @@+export * from "./palo-alto-networks-pki-sync-constants";+export * from "./palo-alto-networks-pki-sync-fns";+export * from "./palo-alto-networks-pki-sync-schemas";+export * from "./palo-alto-networks-pki-sync-types";diff --git a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-constants.ts b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-constants.tsnew file mode 100644index 0000000000..b403c96fb7--- /dev/null+++ b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-constants.ts@@ -0,0 +1,47 @@+import RE2 from "re2";++import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";++const ALLOWED_CHARACTER_PATTERN = "^[a-zA-Z0-9_-]{1,31}$";++export const PALO_ALTO_NETWORKS_NAMING = {+ NAME_PATTERN: new RE2(ALLOWED_CHARACTER_PATTERN),+ FORBIDDEN_CHARACTERS: "!@#$%^&*()+=[]{}|\\:;\"'<>,.?/~` ",+ MAX_NAME_LENGTH: 31,+ MIN_NAME_LENGTH: 1,+ ALLOWED_CHARACTER_PATTERN+} as const;++export const PALO_ALTO_NETWORKS_CA_CERTIFICATE_PREFIX = "INF-CA-";++export const PALO_ALTO_NETWORKS_PKI_SYNC_DESTINATIONS = [+ PkiSync.PaloAltoNetworks,+ PkiSync.PaloAltoNetworksSslTlsProfile+];++const PALO_ALTO_NETWORKS_SHARED_LIST_OPTION = {+ connection: AppConnection.PaloAltoNetworks,+ canImportCertificates: false,+ canRemoveCertificates: true,+ canRunPostSyncCommand: false,+ canRunHealthCheckCommand: false,+ defaultCertificateNameSchema: "INF-{{shortCertificateId}}",+ forbiddenCharacters: PALO_ALTO_NETWORKS_NAMING.FORBIDDEN_CHARACTERS,+ allowedCharacterPattern: PALO_ALTO_NETWORKS_NAMING.ALLOWED_CHARACTER_PATTERN,+ maxCertificateNameLength: PALO_ALTO_NETWORKS_NAMING.MAX_NAME_LENGTH,+ minCertificateNameLength: PALO_ALTO_NETWORKS_NAMING.MIN_NAME_LENGTH+} as const;++export const PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION = {+ ...PALO_ALTO_NETWORKS_SHARED_LIST_OPTION,+ name: "Palo Alto Networks" as const,+ destination: PkiSync.PaloAltoNetworks+} as const;++export const PALO_ALTO_NETWORKS_SSL_TLS_PROFILE_PKI_SYNC_LIST_OPTION = {+ ...PALO_ALTO_NETWORKS_SHARED_LIST_OPTION,+ name: "Palo Alto Networks SSL/TLS Profile" as const,+ destination: PkiSync.PaloAltoNetworksSslTlsProfile,+ maxCertificates: 1+} as const;diff --git a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.test.ts b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.test.tsnew file mode 100644index 0000000000..787ceec2aa--- /dev/null+++ b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.test.ts@@ -0,0 +1,16 @@+import { buildManagedCertNamePattern } from "./palo-alto-networks-pki-sync-fns";++const SHORT_ID = "3hFkQ9xZr2mVw8LpT0aBcD";++describe("Palo Alto Networks buildManagedCertNamePattern (orphan cleanup detection)", () => {+ test("defaults to the INF-{{shortCertificateId}} schema", () => {+ const pattern = buildManagedCertNamePattern(undefined);+ expect(pattern.test(`INF-${SHORT_ID}`)).toBe(true);+ expect(pattern.test("mgmt-cert")).toBe(false);+ });++ test("never treats the imported CA chain objects as managed leaf certificates", () => {+ const pattern = buildManagedCertNamePattern(undefined);+ expect(pattern.test("INF-CA-0123456789abcdef01234567")).toBe(false);+ });+});diff --git a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.ts b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.tsnew file mode 100644index 0000000000..2aca36a32e--- /dev/null+++ b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.ts@@ -0,0 +1,807 @@+/* eslint-disable no-await-in-loop */+import crypto from "crypto";+import RE2 from "re2";++import { TCertificateSyncs } from "@app/db/schemas";+import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";+import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";+import { logger } from "@app/lib/logger";+import {+ describePanOsError,+ getConfigRoot,+ getEntries,+ isPanorama,+ listPanoramaTemplates,+ PAN_OS_LOCALHOST_ENTRY,+ PanOsApiError,+ TPanOsClient,+ withPanOsClient+} from "@app/services/app-connection/palo-alto-networks/palo-alto-networks-connection-fns";+import { TPaloAltoNetworksConnection } from "@app/services/app-connection/palo-alto-networks/palo-alto-networks-connection-types";+import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";+import { splitPemChain } from "@app/services/certificate/certificate-fns";+import { TCertificateSyncDALFactory } from "@app/services/certificate-sync/certificate-sync-dal";+import { TCertificateMap } from "@app/services/pki-sync/pki-sync-types";++import {+ buildManagedCertificateNameRegexSource,+ certificateNameSchemaHasFreeTextPlaceholder,+ compileCertificateNameSchema,+ SHORT_UUID_NAME_REGEX_FRAGMENT,+ UUID_NAME_REGEX_FRAGMENT+} from "../pki-sync-certificate-name-fns";+import { PkiSync } from "../pki-sync-enums";+import { PkiSyncError } from "../pki-sync-errors";+import { TPkiSyncWithCredentials } from "../pki-sync-types";+import {+ PALO_ALTO_NETWORKS_CA_CERTIFICATE_PREFIX,+ PALO_ALTO_NETWORKS_PKI_SYNC_DESTINATIONS,+ PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION+} from "./palo-alto-networks-pki-sync-constants";+import { TPaloAltoNetworksPkiSyncConfig, TPaloAltoNetworksPkiSyncOptions } from "./palo-alto-networks-pki-sync-types";++type TPaloAltoNetworksPkiSyncFactoryDeps = {+ certificateSyncDAL: Pick<+ TCertificateSyncDALFactory,+ | "removeCertificates"+ | "findByPkiSyncId"+ | "findExternalIdentifiersInUse"+ | "claimExternalIdentifier"+ | "setSyncMetadataFlag"+ | "clearSyncMetadataFlag"+ >;+ certificateDAL: Pick<TCertificateDALFactory, "find">;+ gatewayV2Service?: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;+ gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;+};++const DEPLOY_PENDING_FLAG = "panOsDeployPending";+const REMOVE_PENDING_FLAG = "panOsRemovePending";+const PASSPHRASE_VALUE_PATTERN = new RE2("value: \\S+", "g");+const UNSUPPORTED_DESCRIPTION_PATTERN = new RE2("description", "i");+const MAX_COMMIT_DESCRIPTION_LENGTH = 255;++const hasSyncMetadataFlag = (record: TCertificateSyncs, flag: string) =>+ Boolean((record.syncMetadata as Record<string, unknown> | null)?.[flag]);++const hasDeployPending = (records: TCertificateSyncs[]) =>+ records.some((record) => hasSyncMetadataFlag(record, DEPLOY_PENDING_FLAG));++const escapeXml = (value: string) =>+ value+ .replaceAll("&", "&")+ .replaceAll("<", "<")+ .replaceAll(">", ">")+ .replaceAll('"', """)+ .replaceAll("'", "'");++const getFingerprint = (pem: string) => {+ try {+ return new crypto.X509Certificate(pem).fingerprint256;+ } catch {+ return undefined;+ }+};++const getScopeXpath = (config: TPaloAltoNetworksPkiSyncConfig, vsys?: string) =>+ vsys+ ? `${getConfigRoot(config.template)}/devices/${PAN_OS_LOCALHOST_ENTRY}/vsys/entry[@name='${vsys}']`+ : `${getConfigRoot(config.template)}/shared`;++const getCertificatesXpath = (config: TPaloAltoNetworksPkiSyncConfig, vsys?: string) =>+ `${getScopeXpath(config, vsys)}/certificate`;++const getCertificateEntryXpath = (config: TPaloAltoNetworksPkiSyncConfig, name: string) =>+ `${getCertificatesXpath(config)}/entry[@name='${name}']`;++const getProfileXpath = (config: TPaloAltoNetworksPkiSyncConfig) => {+ const scope = getScopeXpath(config, config.sslTlsServiceProfileVsys);+ return `${scope}/ssl-tls-service-profile/entry[@name='${config.sslTlsServiceProfileName}']`;+};++const getImportTarget = ({ template }: TPaloAltoNetworksPkiSyncConfig): Record<string, string> =>+ template ? { "target-tpl": template } : {};++const assertDeviceMatchesConfig = async (client: TPanOsClient, config: TPaloAltoNetworksPkiSyncConfig) => {+ const panorama = await isPanorama(client);+ if (panorama && !config.template) {+ throw new PkiSyncError({+ message:+ "The connection points to a Panorama. Select the template the certificates should be stored in, then sync again.",+ shouldRetry: false+ });+ }+ if (panorama && config.template && !(await listPanoramaTemplates(client)).includes(config.template)) {+ throw new PkiSyncError({+ message: `Template '${config.template}' was not found on the Panorama. Select an existing template, then sync again.`,+ shouldRetry: false+ });+ }+ if (!panorama && config.template) {+ throw new PkiSyncError({+ message: `The connection points to a firewall, not a Panorama, so template '${config.template}' cannot be used. Remove the template from the sync.`,+ shouldRetry: false+ });+ }+ return panorama;+};++const toFingerprintMap = (certificateNode: unknown) =>+ new Map(+ getEntries(certificateNode).map((entry) => [+ String(entry["@_name"]),+ typeof entry["public-key"] === "string" ? getFingerprint(entry["public-key"]) : undefined+ ])+ );++const listCertificates = async (client: TPanOsClient, config: TPaloAltoNetworksPkiSyncConfig, vsys?: string) =>+ toFingerprintMap((await client.getConfig(getCertificatesXpath(config, vsys))).certificate);++const importCaChain = async (+ client: TPanOsClient,+ config: TPaloAltoNetworksPkiSyncConfig,+ certificateChain: string | undefined,+ existingCertificates: Map<string, string | undefined>,+ knownFingerprints: Set<string | undefined>+) => {+ let imported = false;+ for (const caPem of splitPemChain(certificateChain ?? "")) {+ const fingerprint = getFingerprint(caPem);+ // eslint-disable-next-line no-continue+ if (!fingerprint || knownFingerprints.has(fingerprint)) continue;++ const name = `${PALO_ALTO_NETWORKS_CA_CERTIFICATE_PREFIX}${fingerprint.replaceAll(":", "").slice(0, 24).toLowerCase()}`;+ await client.importFile(+ { type: "import", category: "certificate", "certificate-name": name, format: "pem", ...getImportTarget(config) },+ `${name}.pem`,+ caPem+ );+ existingCertificates.set(name, fingerprint);+ knownFingerprints.add(fingerprint);+ imported = true;+ }+ return imported;+};++const importKeyPair = async (+ client: TPanOsClient,+ config: TPaloAltoNetworksPkiSyncConfig,+ name: string,+ cert: string,+ privateKey: string+) => {+ const passphrase = crypto.randomBytes(16).toString("base64url");+ const encryptedKey = crypto+ .createPrivateKey(privateKey)+ .export({ type: "pkcs8", format: "pem", cipher: "aes-256-cbc", passphrase })+ .toString();++ try {+ await client.importFile(+ {+ type: "import",+ category: "keypair",+ "certificate-name": name,+ format: "pem",+ passphrase,+ ...getImportTarget(config)+ },+ `${name}.pem`,+ `${cert.trim()}\n${encryptedKey}`+ );+ } catch (error) {+ throw new PanOsApiError(+ describePanOsError(error)+ .replaceAll(passphrase, "[redacted]")+ .replace(PASSPHRASE_VALUE_PATTERN, "value: [redacted]")+ );+ }+};++const getProfileCertificate = async (client: TPanOsClient, config: TPaloAltoNetworksPkiSyncConfig) => {+ const profile = getEntries(await client.getConfig(getProfileXpath(config)))[0];+ if (!profile) {+ throw new PkiSyncError({+ message: `SSL/TLS service profile '${config.sslTlsServiceProfileName}' was not found${config.sslTlsServiceProfileVsys ? ` in virtual system '${config.sslTlsServiceProfileVsys}'` : ""}. Create it on the device or update the sync.`,+ shouldRetry: false+ });+ }+ return typeof profile.certificate === "string" ? profile.certificate : undefined;+};++const waitForCommitJob = async (client: TPanOsClient, jobId: string | undefined, label: string) => {+ if (!jobId) return;+ const job = await client.waitForJob(jobId);+ const failedDevices = job.devices.filter((device) => device.result !== "OK");+ if (job.result !== "OK" || failedDevices.length > 0) {+ const reasons = failedDevices.length+ ? failedDevices.map((device) => `${device.name}: ${device.details.join(" ") || device.result}`).join("; ")+ : job.details.join(" ");+ throw new PkiSyncError({+ message: `${label} failed${failedDevices.length ? ` on ${failedDevices.length} of ${job.devices.length} firewalls` : ""}: ${reasons || "no details returned"}`,+ shouldRetry: true+ });+ }+};++const startCommitWithDescription = async (+ client: TPanOsClient,+ action: string,+ description: string,+ buildCmd: (descriptionElement: string) => string+) => {+ const descriptionElement = `<description>${escapeXml(description.slice(0, MAX_COMMIT_DESCRIPTION_LENGTH))}</description>`;+ try {+ return await client.startCommit({ action, cmd: buildCmd(descriptionElement) });+ } catch (error) {+ if (!(error instanceof PanOsApiError) || !UNSUPPORTED_DESCRIPTION_PATTERN.test(error.message)) throw error;+ return client.startCommit({ action, cmd: buildCmd("") });+ }+};++const commitAndPush = async (+ client: TPanOsClient,+ config: TPaloAltoNetworksPkiSyncConfig,+ { panorama, description }: { panorama: boolean; description: string }+) => {+ const commitJobId = await startCommitWithDescription(+ client,+ "partial",+ description,+ (descriptionElement) =>+ `<commit><partial>${descriptionElement}<admin><member>${escapeXml(client.username)}</member></admin></partial></commit>`+ );+ await waitForCommitJob(client, commitJobId, panorama ? "Commit to Panorama" : "Commit");++ if (!panorama || !config.pushToDevices || !config.template) return;++ const stacksResult = await client.getConfig(`/config/devices/${PAN_OS_LOCALHOST_ENTRY}/template-stack`);+ const stacks = getEntries(stacksResult["template-stack"])+ .filter((stack) =>+ ((stack.templates as { member?: unknown[] } | undefined)?.member ?? []).map(String).includes(config.template!)+ )+ .map((stack) => String(stack["@_name"]));++ if (stacks.length === 0) {+ throw new PkiSyncError({+ message: `Template '${config.template}' is not part of any template stack, so it cannot be pushed to firewalls. Add it to a template stack, or turn off Push to Devices.`,+ shouldRetry: false+ });+ }++ for (const stack of stacks) {+ await waitForCommitJob(+ client,+ await startCommitWithDescription(+ client,+ "all",+ description,+ (descriptionElement) =>+ `<commit-all><template-stack><name>${escapeXml(stack)}</name>${descriptionElement}</template-stack></commit-all>`+ ),+ `Push of template stack '${stack}'`+ );+ }+};++export const buildManagedCertNamePattern = (certificateNameSchema: string | undefined): RE2 => {+ const pattern = buildManagedCertificateNameRegexSource(+ certificateNameSchema ?? PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION.defaultCertificateNameSchema,+ {+ uuid: UUID_NAME_REGEX_FRAGMENT,+ shortUuid: SHORT_UUID_NAME_REGEX_FRAGMENT,+ freeText: "[a-zA-Z0-9_-]*"+ }+ );+ return new RE2(`^${pattern}$`);+};++type TPlannedUpload = TCertificateMap[string] & {+ mapKey: string;+ name: string;+ oldCertificateIdToRemove?: string;+};++type TSyncFailure = { name: string; error: string };++const planUploads = ({+ pkiSync,+ certificateMap,+ syncRecordsByCertId,+ certificatesById,+ existingCertificates,+ removePendingCertificateIds+}: {+ pkiSync: TPkiSyncWithCredentials;+ certificateMap: TCertificateMap;+ syncRecordsByCertId: Map<string, TCertificateSyncs>;+ certificatesById: Map<string, { renewedByCertificateId?: string | null; renewedFromCertificateId?: string | null }>;+ existingCertificates: Map<string, string | undefined>;+ removePendingCertificateIds: Set<string>;+}) => {+ const { preserveItemOnRenewal, certificateNameSchema } = pkiSync.syncOptions as TPaloAltoNetworksPkiSyncOptions;+ const plannedUploads: TPlannedUpload[] = [];+ const activeNames = new Set<string>();+ const skippedCertificates: Array<{ name: string; reason: string }> = [];++ for (const [mapKey, certData] of Object.entries(certificateMap)) {+ const { cert, privateKey, certificateId } = certData;++ // eslint-disable-next-line no-continue+ if (certificateId && removePendingCertificateIds.has(certificateId)) continue;++ if (!cert || !privateKey) {+ const existingName = certificateId ? syncRecordsByCertId.get(certificateId)?.externalIdentifier : undefined;+ if (existingName) activeNames.add(existingName);+ skippedCertificates.push({ name: mapKey, reason: "Missing certificate or private key data" });+ // eslint-disable-next-line no-continue+ continue;+ }++ const certificate = certificateId ? certificatesById.get(certificateId) : undefined;+ if (certificate?.renewedByCertificateId) {+ skippedCertificates.push({+ name: mapKey,+ reason: "Certificate has been renewed and replaced by a newer certificate"+ });+ // eslint-disable-next-line no-continue+ continue;+ }++ let name = mapKey;+ let oldCertificateIdToRemove: string | undefined;++ if (certificateId) {+ const renewedFromRecord = certificate?.renewedFromCertificateId+ ? syncRecordsByCertId.get(certificate.renewedFromCertificateId)+ : undefined;+ const directRecord = syncRecordsByCertId.get(certificateId);++ if (renewedFromRecord?.externalIdentifier && preserveItemOnRenewal) {+ name = renewedFromRecord.externalIdentifier;+ oldCertificateIdToRemove = certificate?.renewedFromCertificateId ?? undefined;+ } else if (certificate?.renewedFromCertificateId && !preserveItemOnRenewal) {+ name = compileCertificateNameSchema(+ certificateNameSchema ?? PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION.defaultCertificateNameSchema,+ {+ certificateId,+ profileId: certData.profileId,+ applicationId: pkiSync.applicationId,+ applicationName: pkiSync.applicationName,+ commonName: certData.commonName+ },+ PkiSync.PaloAltoNetworks+ );+ } else if (directRecord?.externalIdentifier && existingCertificates.has(directRecord.externalIdentifier)) {+ name = directRecord.externalIdentifier;+ }+ }++ activeNames.add(name);+ plannedUploads.push({ ...certData, mapKey, name, oldCertificateIdToRemove });+ }++ return { plannedUploads, activeNames, skippedCertificates };+};++const getNewestLinkedUpload = (uploads: TPlannedUpload[], syncRecordsByCertId: Map<string, TCertificateSyncs>) => {+ const linkedAt = (upload: TPlannedUpload) =>+ syncRecordsByCertId.get(upload.certificateId ?? "")?.createdAt?.getTime() ?? Number.MAX_SAFE_INTEGER;+ return uploads.reduce<TPlannedUpload | undefined>(+ (newest, upload) => (!newest || linkedAt(upload) >= linkedAt(newest) ? upload : newest),+ undefined+ );+};++export const paloAltoNetworksPkiSyncFactory = ({+ certificateSyncDAL,+ certificateDAL,+ gatewayV2Service,+ gatewayPoolService+}: TPaloAltoNetworksPkiSyncFactoryDeps) => {+ const withClient = async <T>(+ pkiSync: TPkiSyncWithCredentials,+ operation: (client: TPanOsClient, panorama: boolean, config: TPaloAltoNetworksPkiSyncConfig) => Promise<T>+ ) => {+ const connection = {+ ...pkiSync.connection,+ credentials: pkiSync.connection.credentials as TPaloAltoNetworksConnection["credentials"]+ };+ const config = pkiSync.destinationConfig as TPaloAltoNetworksPkiSyncConfig;+ let pkiSyncError: PkiSyncError | undefined;++ try {+ return await withPanOsClient(connection, { gatewayV2Service, gatewayPoolService }, async (client) => {+ try {+ return await operation(client, await assertDeviceMatchesConfig(client, config), config);+ } catch (error) {+ if (error instanceof PkiSyncError) pkiSyncError = error;+ throw error;+ }+ });+ } catch (error) {+ if (pkiSyncError) throw pkiSyncError;+ throw new PkiSyncError({+ message: `Palo Alto Networks device '${connection.credentials.hostname}' could not complete the request: ${describePanOsError(error)}`,+ cause: error instanceof Error ? error : undefined,+ shouldRetry: true+ });+ }+ };++ const createDeployPendingMarker = (pkiSyncId: string) => {+ let isMarked = false;+ return {+ mark: async () => {+ if (isMarked) return;+ await certificateSyncDAL.setSyncMetadataFlag(pkiSyncId, DEPLOY_PENDING_FLAG);+ isMarked = true;+ },+ isMarked: () => isMarked+ };+ };++ type TDeployPendingMarker = ReturnType<typeof createDeployPendingMarker>;++ const finishDeploy = async ({+ client,+ config,+ panorama,+ pkiSyncId,+ existingSyncRecords,+ hasDeviceChanges,+ deployPending,+ description+ }: {+ client: TPanOsClient;+ config: TPaloAltoNetworksPkiSyncConfig;+ panorama: boolean;+ pkiSyncId: string;+ description: string;+ existingSyncRecords: TCertificateSyncs[];+ hasDeviceChanges: boolean;+ deployPending: TDeployPendingMarker;+ }) => {+ const isDeployPending = hasDeployPending(existingSyncRecords);+ if (hasDeviceChanges || isDeployPending) {+ await commitAndPush(client, config, { panorama, description });+ }+ if (isDeployPending || deployPending.isMarked()) {+ await certificateSyncDAL.clearSyncMetadataFlag(pkiSyncId, DEPLOY_PENDING_FLAG);+ }+ };++ const importPlannedUploads = async ({+ client,+ config,+ pkiSyncId,+ plannedUploads,+ existingCertificates,+ knownCaFingerprints,+ deployPending+ }: {+ client: TPanOsClient;+ config: TPaloAltoNetworksPkiSyncConfig;+ pkiSyncId: string;+ plannedUploads: TPlannedUpload[];+ existingCertificates: Map<string, string | undefined>;+ knownCaFingerprints: Set<string | undefined>;+ deployPending: TDeployPendingMarker;+ }) => {+ const succeeded: TPlannedUpload[] = [];+ const failedUploads: TSyncFailure[] = [];+ let hasDeviceChanges = false;+ if (plannedUploads.length) await deployPending.mark();++ for (const upload of plannedUploads) {+ try {+ if (upload.certificateId) {+ await certificateSyncDAL.claimExternalIdentifier(pkiSyncId, upload.certificateId, upload.name);+ }++ const importedCa = await importCaChain(+ client,+ config,+ upload.fullCertificateChain ?? upload.certificateChain,+ existingCertificates,+ knownCaFingerprints+ );+ hasDeviceChanges ||= importedCa;++ const fingerprint = getFingerprint(upload.cert);+ if (!fingerprint || existingCertificates.get(upload.name) !== fingerprint) {+ await importKeyPair(client, config, upload.name, upload.cert, upload.privateKey);+ hasDeviceChanges = true;+ existingCertificates.set(upload.name, fingerprint);+ }++ succeeded.push(upload);+ } catch (error) {+ failedUploads.push({ name: upload.mapKey, error: describePanOsError(error) });+ logger.error(+ { error },+ `Palo Alto Networks PKI sync failed to import certificate [syncId=${pkiSyncId}] [name=${upload.name}]`+ );+ }+ }++ return { succeeded, failedUploads, hasDeviceChanges };+ };++ const removeOrphanedCertificates = async ({+ client,+ config,+ pkiSync,+ existingSyncRecords,+ existingCertificates,+ activeNames,+ deployPending+ }: {+ client: TPanOsClient;+ config: TPaloAltoNetworksPkiSyncConfig;+ pkiSync: TPkiSyncWithCredentials;+ existingSyncRecords: TCertificateSyncs[];+ existingCertificates: Map<string, string | undefined>;+ activeNames: Set<string>;+ deployPending: TDeployPendingMarker;+ }) => {+ const { certificateNameSchema } = pkiSync.syncOptions as TPaloAltoNetworksPkiSyncOptions;+ const failedRemovals: TSyncFailure[] = [];+ let removedCount = 0;++ const candidates = new Set(+ existingSyncRecords+ .map((record) => record.externalIdentifier)+ .filter(+ (name): name is string =>+ Boolean(name) && !activeNames.has(name as string) && existingCertificates.has(name as string)+ )+ );++ if (!certificateNameSchemaHasFreeTextPlaceholder(certificateNameSchema)) {+ const managedPattern = buildManagedCertNamePattern(certificateNameSchema);+ existingCertificates.forEach((_, name) => {+ if (+ managedPattern.test(name) &&+ !activeNames.has(name) &&+ !name.startsWith(PALO_ALTO_NETWORKS_CA_CERTIFICATE_PREFIX)+ ) {+ candidates.add(name);+ }+ });+ }++ const ownedByOtherSync = await certificateSyncDAL.findExternalIdentifiersInUse([...candidates], {+ excludePkiSyncId: pkiSync.id,+ destination: PALO_ALTO_NETWORKS_PKI_SYNC_DESTINATIONS+ });++ for (const name of candidates) {+ // eslint-disable-next-line no-continue+ if (ownedByOtherSync.has(name)) continue;+ await deployPending.mark();+ try {+ await client.deleteConfig(getCertificateEntryXpath(config, name));+ existingCertificates.delete(name);+ removedCount += 1;+ } catch (error) {+ failedRemovals.push({ name, error: describePanOsError(error) });+ }+ }++ return { removedCount, failedRemovals };+ };++ const syncCertificates = async (pkiSync: TPkiSyncWithCredentials, certificateMap: TCertificateMap) => {+ const { canRemoveCertificates } = pkiSync.syncOptions as TPaloAltoNetworksPkiSyncOptions;++ const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);+ const syncRecordsByCertId = new Map(+ existingSyncRecords+ .filter((record) => record.certificateId)+ .map((record) => [record.certificateId as string, record])+ );+ const certificateIds = Object.values(certificateMap)+ .map((certData) => certData.certificateId)+ .filter((id): id is string => Boolean(id));++ const flaggedForRemoval = new Set(+ existingSyncRecords+ .filter((record) => record.certificateId && hasSyncMetadataFlag(record, REMOVE_PENDING_FLAG))+ .map((record) => record.certificateId as string)+ );+ const hasReplacement = certificateIds.some((certificateId) => !flaggedForRemoval.has(certificateId));+ const removePendingCertificateIds = hasReplacement ? flaggedForRemoval : new Set<string>();+ if (flaggedForRemoval.size && !hasReplacement) {+ await certificateSyncDAL.clearSyncMetadataFlag(pkiSync.id, REMOVE_PENDING_FLAG);+ }+ const certificatesById = new Map(+ certificateIds.length+ ? (await certificateDAL.find({ $in: { id: certificateIds } })).map((certificate) => [+ certificate.id,+ certificate+ ])+ : []+ );++ return withClient(pkiSync, async (client, panorama, config) => {+ const [existingCertificates, profileVsysCertificates, profileCertificate] = await Promise.all([+ listCertificates(client, config),+ config.sslTlsServiceProfileVsys+ ? listCertificates(client, config, config.sslTlsServiceProfileVsys)+ : new Map<string, string | undefined>(),+ config.sslTlsServiceProfileName ? getProfileCertificate(client, config) : undefined+ ]);+ const knownCaFingerprints = new Set([...existingCertificates.values(), ...profileVsysCertificates.values()]);+ const deployPending = createDeployPendingMarker(pkiSync.id);++ const { plannedUploads, activeNames, skippedCertificates } = planUploads({+ pkiSync,+ certificateMap,+ syncRecordsByCertId,+ certificatesById,+ existingCertificates,+ removePendingCertificateIds+ });++ const imports = await importPlannedUploads({+ client,+ config,+ pkiSyncId: pkiSync.id,+ plannedUploads,+ existingCertificates,+ knownCaFingerprints,+ deployPending+ });+ let { hasDeviceChanges } = imports;++ const profileTarget = config.sslTlsServiceProfileName+ ? getNewestLinkedUpload(imports.succeeded, syncRecordsByCertId)+ : undefined;+ if (profileTarget && profileCertificate !== profileTarget.name) {+ await deployPending.mark();+ await client.editConfig(+ `${getProfileXpath(config)}/certificate`,+ `<certificate>${profileTarget.name}</certificate>`+ );+ hasDeviceChanges = true;+ }++ const removals = canRemoveCertificates+ ? await removeOrphanedCertificates({+ client,+ config,+ pkiSync,+ existingSyncRecords,+ existingCertificates,+ activeNames,+ deployPending+ })+ : { removedCount: 0, failedRemovals: [] };+ hasDeviceChanges ||= removals.removedCount > 0;++ await finishDeploy({+ client,+ config,+ panorama,+ pkiSyncId: pkiSync.id,+ existingSyncRecords,+ hasDeviceChanges,+ deployPending,+ description: `Infisical certificate sync: ${pkiSync.name}`+ });++ const replacedCertificateIds = [+ ...imports.succeeded.map((upload) => upload.oldCertificateIdToRemove),+ ...[...removePendingCertificateIds].filter(+ (certificateId) => !existingCertificates.has(syncRecordsByCertId.get(certificateId)?.externalIdentifier ?? "")+ )+ ].filter((id): id is string => Boolean(id));+ if (replacedCertificateIds.length) {+ await certificateSyncDAL.removeCertificates(pkiSync.id, replacedCertificateIds);+ }++ return {+ uploaded: imports.succeeded.length,+ removed: removals.removedCount || undefined,+ failedRemovals: removals.failedRemovals.length || undefined,+ skipped: skippedCertificates.length,+ details: {+ failedUploads: imports.failedUploads.length ? imports.failedUploads : undefined,+ failedRemovals: removals.failedRemovals.length ? removals.failedRemovals : undefined,+ skippedCertificates: skippedCertificates.length ? skippedCertificates : undefined+ }+ };+ });+ };++ const removeCertificates = async (+ pkiSync: TPkiSyncWithCredentials,+ certificateNames: string[],+ deps?: { certificateMap?: TCertificateMap }+ ): Promise<void> => {+ const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);+ const syncRecordsByCertId = new Map(existingSyncRecords.map((record) => [record.certificateId ?? "", record]));++ const targets = certificateNames+ .map((certName) => syncRecordsByCertId.get(deps?.certificateMap?.[certName]?.certificateId ?? ""))+ .filter((record): record is TCertificateSyncs & { externalIdentifier: string; certificateId: string } =>+ Boolean(record?.externalIdentifier && record.certificateId)+ );++ if (targets.length === 0) return;++ const targetCertificateIds = new Set(targets.map((target) => target.certificateId));+ const replacementRecords = existingSyncRecords+ .filter((record) => record.certificateId && !targetCertificateIds.has(record.certificateId))+ .sort((a, b) => (b.createdAt?.getTime() ?? 0) - (a.createdAt?.getTime() ?? 0));++ const deferredCertificateIds = await withClient(pkiSync, async (client, panorama, config) => {+ const [existingCertificates, profileCertificate] = await Promise.all([+ listCertificates(client, config),+ config.sslTlsServiceProfileName && replacementRecords.length ? getProfileCertificate(client, config) : undefined+ ]);+ const deployPending = createDeployPendingMarker(pkiSync.id);+ let hasDeviceChanges = false;+ const deferred = new Set<string>();++ if (targets.some((target) => target.externalIdentifier === profileCertificate)) {+ const replacementOnDevice = replacementRecords.find(+ (record) => record.externalIdentifier && existingCertificates.has(record.externalIdentifier)+ );+ if (replacementOnDevice) {+ await deployPending.mark();+ await client.editConfig(+ `${getProfileXpath(config)}/certificate`,+ `<certificate>${replacementOnDevice.externalIdentifier}</certificate>`+ );+ hasDeviceChanges = true;+ await certificateSyncDAL.clearSyncMetadataFlag(pkiSync.id, REMOVE_PENDING_FLAG, undefined, [+ replacementOnDevice.certificateId as string+ ]);+ } else {+ targets+ .filter((target) => target.externalIdentifier === profileCertificate)+ .forEach((target) => deferred.add(target.certificateId));+ await certificateSyncDAL.setSyncMetadataFlag(pkiSync.id, REMOVE_PENDING_FLAG, [...deferred]);+ }+ }++ for (const { externalIdentifier, certificateId } of targets) {+ // eslint-disable-next-line no-continue+ if (deferred.has(certificateId) || !existingCertificates.has(externalIdentifier)) continue;+ await deployPending.mark();+ try {+ await client.deleteConfig(getCertificateEntryXpath(config, externalIdentifier));+ hasDeviceChanges = true;+ } catch (error) {+ throw new PkiSyncError({+ message: `Failed to remove certificate '${externalIdentifier}' from Palo Alto Networks: ${describePanOsError(error)}`,+ shouldRetry: true+ });+ }+ }++ await finishDeploy({+ client,+ config,+ panorama,+ pkiSyncId: pkiSync.id,+ existingSyncRecords,+ hasDeviceChanges,+ deployPending,+ description: `Infisical certificate removal: ${pkiSync.name}`+ });+ return deferred;+ });++ const removedCertificateIds = [...targetCertificateIds].filter(+ (certificateId) => !deferredCertificateIds.has(certificateId)+ );+ if (removedCertificateIds.length) await certificateSyncDAL.removeCertificates(pkiSync.id, removedCertificateIds);+ };++ const testReachability = (pkiSync: TPkiSyncWithCredentials) => withClient(pkiSync, async () => undefined);++ return { syncCertificates, removeCertificates, testReachability };+};diff --git a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.test.ts b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.test.tsnew file mode 100644index 0000000000..8d4fac51fc--- /dev/null+++ b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.test.ts@@ -0,0 +1,48 @@+import {+ PaloAltoNetworksPkiSyncConfigSchema,+ PaloAltoNetworksPkiSyncOptionsSchema,+ PaloAltoNetworksSslTlsProfilePkiSyncConfigSchema+} from "./palo-alto-networks-pki-sync-schemas";++const parseNameSchema = (certificateNameSchema: string) =>+ PaloAltoNetworksPkiSyncOptionsSchema.safeParse({ certificateNameSchema }).success;++describe("Palo Alto Networks certificateNameSchema validation", () => {+ test("accepts the default and short-id schemas within the 31-char Panorama limit", () => {+ expect(parseNameSchema("INF-{{shortCertificateId}}")).toBe(true);+ expect(parseNameSchema("web-{{shortCertificateId}}")).toBe(true);+ });++ test("rejects schemas that compile beyond 31 characters", () => {+ expect(parseNameSchema("{{certificateId}}")).toBe(false);+ expect(parseNameSchema("Infisical-{{shortCertificateId}}")).toBe(false);+ });++ test("rejects periods, which PAN-OS certificate names do not allow", () => {+ expect(parseNameSchema("web.{{shortCertificateId}}")).toBe(false);+ });+});++describe("Palo Alto Networks destination config validation", () => {+ test("certificates sync accepts a firewall config and defaults push to devices on", () => {+ expect(PaloAltoNetworksPkiSyncConfigSchema.parse({}).pushToDevices).toBe(true);+ });++ test("SSL/TLS profile sync requires a profile and accepts a template vsys", () => {+ expect(PaloAltoNetworksSslTlsProfilePkiSyncConfigSchema.safeParse({ template: "branch-tpl" }).success).toBe(false);+ expect(+ PaloAltoNetworksSslTlsProfilePkiSyncConfigSchema.safeParse({+ template: "branch-tpl",+ sslTlsServiceProfileName: "gp-portal-profile",+ sslTlsServiceProfileVsys: "vsys1"+ }).success+ ).toBe(true);+ });++ test("rejects names that could break out of an XPath predicate", () => {+ expect(PaloAltoNetworksPkiSyncConfigSchema.safeParse({ template: "a']/../entry[@name='b" }).success).toBe(false);+ expect(+ PaloAltoNetworksSslTlsProfilePkiSyncConfigSchema.safeParse({ sslTlsServiceProfileName: "p<x/>" }).success+ ).toBe(false);+ });+});diff --git a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.ts b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.tsnew file mode 100644index 0000000000..9174aae57b--- /dev/null+++ b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.ts@@ -0,0 +1,77 @@+import { z } from "zod";++import { openApiHidden } from "@app/server/lib/schemas";+import { PanOsObjectNameSchema } from "@app/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas";+import { pkiDescriptionSchema } from "@app/services/certificate-common/certificate-constants";+import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";+import {+ BasePkiSyncOptionsSchema,+ buildDestinationCertificateNameSchema,+ PkiSyncFiltersField,+ PkiSyncSchema,+ UpdatePkiSyncFiltersField+} from "@app/services/pki-sync/pki-sync-schemas";++import { PALO_ALTO_NETWORKS_NAMING } from "./palo-alto-networks-pki-sync-constants";++export const PaloAltoNetworksPkiSyncConfigSchema = z.object({+ template: PanOsObjectNameSchema("Template").optional(),+ pushToDevices: z.boolean().default(true)+});++export const PaloAltoNetworksSslTlsProfilePkiSyncConfigSchema = PaloAltoNetworksPkiSyncConfigSchema.extend({+ sslTlsServiceProfileName: PanOsObjectNameSchema("SSL/TLS service profile"),+ sslTlsServiceProfileVsys: PanOsObjectNameSchema("Virtual system").optional()+});++export const PaloAltoNetworksPkiSyncOptionsSchema = BasePkiSyncOptionsSchema.extend({+ certificateNameSchema: buildDestinationCertificateNameSchema({+ naming: PALO_ALTO_NETWORKS_NAMING,+ message:+ "Certificate name schema must result in names that contain only alphanumeric characters, hyphens (-), and underscores (_) and be 1-31 characters long for Palo Alto Networks. Use {{shortCertificateId}} rather than {{certificateId}} to stay within the limit. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema with no placeholder can be linked to only one certificate."+ })+});++const buildPaloAltoNetworksPkiSyncSchemas = <TDestination extends PkiSync, TConfig extends z.AnyZodObject>(+ destination: TDestination,+ destinationConfig: TConfig+) => ({+ responseSchema: PkiSyncSchema.extend({+ destination: z.literal(destination),+ destinationConfig,+ syncOptions: PaloAltoNetworksPkiSyncOptionsSchema+ }),+ createSchema: z.object({+ name: z.string().trim().min(1).max(256),+ description: pkiDescriptionSchema.optional(),+ isAutoSyncEnabled: z.boolean().default(true),+ destinationConfig: destinationConfig.strict(),+ syncOptions: PaloAltoNetworksPkiSyncOptionsSchema,+ subscriberId: z.string().uuid().nullish(),+ connectionId: z.string().uuid(),+ projectId: z.string().trim().min(1).optional().describe(openApiHidden()),+ applicationId: z.string().uuid().optional(),+ certificateIds: z.array(z.string().uuid()).optional(),+ filters: PkiSyncFiltersField+ }),+ updateSchema: z.object({+ name: z.string().trim().min(1).max(256).optional(),+ description: pkiDescriptionSchema.optional(),+ isAutoSyncEnabled: z.boolean().optional(),+ destinationConfig: destinationConfig.strict().optional(),+ syncOptions: PaloAltoNetworksPkiSyncOptionsSchema.optional(),+ subscriberId: z.string().uuid().nullish(),+ connectionId: z.string().uuid().optional(),+ filters: UpdatePkiSyncFiltersField+ })+});++export const PaloAltoNetworksPkiSyncSchemas = buildPaloAltoNetworksPkiSyncSchemas(+ PkiSync.PaloAltoNetworks,+ PaloAltoNetworksPkiSyncConfigSchema+);++export const PaloAltoNetworksSslTlsProfilePkiSyncSchemas = buildPaloAltoNetworksPkiSyncSchemas(+ PkiSync.PaloAltoNetworksSslTlsProfile,+ PaloAltoNetworksSslTlsProfilePkiSyncConfigSchema+);diff --git a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-types.ts b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-types.tsnew file mode 100644index 0000000000..766bdb42fc--- /dev/null+++ b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-types.ts@@ -0,0 +1,17 @@+import { z } from "zod";++import {+ PaloAltoNetworksPkiSyncConfigSchema,+ PaloAltoNetworksPkiSyncOptionsSchema,+ PaloAltoNetworksSslTlsProfilePkiSyncConfigSchema+} from "./palo-alto-networks-pki-sync-schemas";++export type TPaloAltoNetworksPkiSyncOptions = z.infer<typeof PaloAltoNetworksPkiSyncOptionsSchema>;++export type TPaloAltoNetworksPkiSyncConfig = z.infer<typeof PaloAltoNetworksPkiSyncConfigSchema> &+ Partial<+ Pick<+ z.infer<typeof PaloAltoNetworksSslTlsProfilePkiSyncConfigSchema>,+ "sslTlsServiceProfileName" | "sslTlsServiceProfileVsys"+ >+ >;diff --git a/backend/src/services/pki-sync/pki-sync-certificate-name-fns.ts b/backend/src/services/pki-sync/pki-sync-certificate-name-fns.tsindex 4f26c2a935..8a0721b907 100644--- a/backend/src/services/pki-sync/pki-sync-certificate-name-fns.ts+++ b/backend/src/services/pki-sync/pki-sync-certificate-name-fns.ts@@ -28,6 +28,8 @@ export const shortenUuid = (uuid: string): string => {const UUID_TEST_VALUE = "0".repeat(32);const SHORT_UUID_TEST_VALUE = "0".repeat(SHORTENED_UUID_LENGTH);+const PAN_OS_NAME_DISALLOWED_CHARS = new RE2("[^a-zA-Z0-9_-]", "g");+// Per-destination set of characters allowed in a resource name. Free-text placeholder values// ({{commonName}} and {{applicationName}}) are sanitized to this set at compile time so a value// like "app.example.com" can't produce a name the destination rejects (e.g. Azure Key Vault and@@ -41,6 +43,8 @@ const NAME_VALUE_DISALLOWED_CHARS: Partial<Record<PkiSync, RE2>> = {[PkiSync.AwsElasticLoadBalancer]: new RE2("[^a-zA-Z0-9 _-]", "g"),[PkiSync.AwsSecretsManager]: new RE2("[^a-zA-Z0-9_-]", "g"),[PkiSync.NetScaler]: new RE2("[^a-zA-Z0-9._-]", "g"),+ [PkiSync.PaloAltoNetworks]: PAN_OS_NAME_DISALLOWED_CHARS,+ [PkiSync.PaloAltoNetworksSslTlsProfile]: PAN_OS_NAME_DISALLOWED_CHARS,[PkiSync.F5BigIp]: new RE2("[^a-zA-Z0-9._-]", "g"),[PkiSync.KempLoadMaster]: new RE2("[^a-zA-Z0-9._-]", "g"),[PkiSync.LinuxServer]: new RE2("[^a-zA-Z0-9._-]", "g"),diff --git a/backend/src/services/pki-sync/pki-sync-enums.ts b/backend/src/services/pki-sync/pki-sync-enums.tsindex bd722ff5cb..345ff9ce75 100644--- a/backend/src/services/pki-sync/pki-sync-enums.ts+++ b/backend/src/services/pki-sync/pki-sync-enums.ts@@ -7,6 +7,8 @@ export enum PkiSync {GcpCertificateManager = "gcp-certificate-manager",CloudflareCustomCertificate = "cloudflare-custom-certificate",NetScaler = "netscaler",+ PaloAltoNetworks = "palo-alto-networks",+ PaloAltoNetworksSslTlsProfile = "palo-alto-networks-ssl-tls-profile",F5BigIp = "f5-big-ip",KempLoadMaster = "kemp-loadmaster",LinuxServer = "linux-server",diff --git a/backend/src/services/pki-sync/pki-sync-fns.ts b/backend/src/services/pki-sync/pki-sync-fns.tsindex 256a5e424c..75d9d4d319 100644--- a/backend/src/services/pki-sync/pki-sync-fns.ts+++ b/backend/src/services/pki-sync/pki-sync-fns.ts@@ -46,6 +46,11 @@ import { NETSCALER_PKI_SYNC_LIST_OPTION } from "./netscaler/netscaler-pki-sync-cimport { netScalerPkiSyncFactory } from "./netscaler/netscaler-pki-sync-fns";import { NUTANIX_PRISM_CENTRAL_PKI_SYNC_LIST_OPTION } from "./nutanix-prism-central/nutanix-prism-central-pki-sync-constants";import { nutanixPrismCentralPkiSyncFactory } from "./nutanix-prism-central/nutanix-prism-central-pki-sync-fns";+import {+ PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION,+ PALO_ALTO_NETWORKS_SSL_TLS_PROFILE_PKI_SYNC_LIST_OPTION+} from "./palo-alto-networks/palo-alto-networks-pki-sync-constants";+import { paloAltoNetworksPkiSyncFactory } from "./palo-alto-networks/palo-alto-networks-pki-sync-fns";import {buildManagedCertificateNameRegexSource,certificateNameSchemaAllowsMultipleCertificates,@@ -84,6 +89,8 @@ const PKI_SYNC_LIST_OPTIONS = {[PkiSync.GcpCertificateManager]: GCP_CERTIFICATE_MANAGER_PKI_SYNC_LIST_OPTION,[PkiSync.CloudflareCustomCertificate]: CLOUDFLARE_CUSTOM_CERTIFICATE_PKI_SYNC_LIST_OPTION,[PkiSync.NetScaler]: NETSCALER_PKI_SYNC_LIST_OPTION,+ [PkiSync.PaloAltoNetworks]: PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION,+ [PkiSync.PaloAltoNetworksSslTlsProfile]: PALO_ALTO_NETWORKS_SSL_TLS_PROFILE_PKI_SYNC_LIST_OPTION,[PkiSync.F5BigIp]: F5_BIG_IP_PKI_SYNC_LIST_OPTION,[PkiSync.KempLoadMaster]: KEMP_LOADMASTER_PKI_SYNC_LIST_OPTION,[PkiSync.LinuxServer]: LINUX_SERVER_PKI_SYNC_LIST_OPTION,@@ -247,6 +254,10 @@ export const PkiSyncFns = {"NetScaler does not support importing certificates into Infisical (private keys cannot be extracted)");}+ case PkiSync.PaloAltoNetworks:+ case PkiSync.PaloAltoNetworksSslTlsProfile: {+ throw new Error("Palo Alto Networks does not support importing certificates into Infisical");+ }case PkiSync.F5BigIp: {throw new Error("F5 BIG-IP does not support importing certificates into Infisical");}@@ -356,6 +367,16 @@ export const PkiSyncFns = {});return netScalerPkiSync.syncCertificates(pkiSync, certificateMap);}+ case PkiSync.PaloAltoNetworks:+ case PkiSync.PaloAltoNetworksSslTlsProfile: {+ const paloAltoNetworksPkiSync = paloAltoNetworksPkiSyncFactory({+ certificateDAL: dependencies.certificateDAL,+ certificateSyncDAL: dependencies.certificateSyncDAL,+ gatewayV2Service: dependencies.gatewayV2Service,+ gatewayPoolService: dependencies.gatewayPoolService+ });+ return paloAltoNetworksPkiSync.syncCertificates(pkiSync, certificateMap);+ }case PkiSync.F5BigIp: {checkPkiSyncDestination(pkiSync, PkiSync.F5BigIp as PkiSync);const f5BigIpPkiSync = f5BigIpPkiSyncFactory({@@ -471,12 +492,25 @@ export const PkiSyncFns = {pkiSync: THealthCheckTarget,dependencies: {certificateSyncDAL: TCertificateSyncDALFactory;- certificateDAL: Pick<TCertificateDALFactory, "findActiveCertificatesByIds">;+ certificateDAL: Pick<TCertificateDALFactory, "findActiveCertificatesByIds" | "find">;gatewayV2Service?: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId" | "getGatewayById">;gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;keyStore: Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry">;}): Promise<void> => {+ if (+ pkiSync.destination === PkiSync.PaloAltoNetworks ||+ pkiSync.destination === PkiSync.PaloAltoNetworksSslTlsProfile+ ) {+ await paloAltoNetworksPkiSyncFactory({+ certificateDAL: dependencies.certificateDAL,+ certificateSyncDAL: dependencies.certificateSyncDAL,+ gatewayV2Service: dependencies.gatewayV2Service,+ gatewayPoolService: dependencies.gatewayPoolService+ }).testReachability(pkiSync as unknown as TPkiSyncWithCredentials);+ return;+ }+if (pkiSync.destination === PkiSync.LinuxServer) {const linuxServerPkiSync = linuxServerPkiSyncFactory({certificateSyncDAL: dependencies.certificateSyncDAL,@@ -613,6 +647,19 @@ export const PkiSyncFns = {});break;}+ case PkiSync.PaloAltoNetworks:+ case PkiSync.PaloAltoNetworksSslTlsProfile: {+ const paloAltoNetworksPkiSync = paloAltoNetworksPkiSyncFactory({+ certificateDAL: dependencies.certificateDAL,+ certificateSyncDAL: dependencies.certificateSyncDAL,+ gatewayV2Service: dependencies.gatewayV2Service,+ gatewayPoolService: dependencies.gatewayPoolService+ });+ await paloAltoNetworksPkiSync.removeCertificates(pkiSync, certificateNames, {+ certificateMap: dependencies.certificateMap+ });+ break;+ }case PkiSync.F5BigIp: {checkPkiSyncDestination(pkiSync, PkiSync.F5BigIp as PkiSync);const f5BigIpPkiSync = f5BigIpPkiSyncFactory({diff --git a/backend/src/services/pki-sync/pki-sync-maps.ts b/backend/src/services/pki-sync/pki-sync-maps.tsindex 7c9a73c506..00583af5aa 100644--- a/backend/src/services/pki-sync/pki-sync-maps.ts+++ b/backend/src/services/pki-sync/pki-sync-maps.ts@@ -11,6 +11,8 @@ export const PKI_SYNC_NAME_MAP: Record<PkiSync, string> = {[PkiSync.GcpCertificateManager]: "GCP Certificate Manager",[PkiSync.CloudflareCustomCertificate]: "Cloudflare Custom SSL Certificate",[PkiSync.NetScaler]: "NetScaler",+ [PkiSync.PaloAltoNetworks]: "Palo Alto Networks",+ [PkiSync.PaloAltoNetworksSslTlsProfile]: "Palo Alto Networks SSL/TLS Profile",[PkiSync.F5BigIp]: "F5 BIG-IP",[PkiSync.KempLoadMaster]: "Kemp LoadMaster",[PkiSync.LinuxServer]: "Linux Server",@@ -27,6 +29,8 @@ export const PKI_SYNC_CONNECTION_MAP: Record<PkiSync, AppConnection> = {[PkiSync.GcpCertificateManager]: AppConnection.GCP,[PkiSync.CloudflareCustomCertificate]: AppConnection.Cloudflare,[PkiSync.NetScaler]: AppConnection.NetScaler,+ [PkiSync.PaloAltoNetworks]: AppConnection.PaloAltoNetworks,+ [PkiSync.PaloAltoNetworksSslTlsProfile]: AppConnection.PaloAltoNetworks,[PkiSync.F5BigIp]: AppConnection.F5BigIp,[PkiSync.KempLoadMaster]: AppConnection.KempLoadMaster,[PkiSync.LinuxServer]: AppConnection.SSH,diff --git a/backend/src/services/pki-sync/pki-sync-queue.ts b/backend/src/services/pki-sync/pki-sync-queue.tsindex 37faa443ef..c62df136dc 100644--- a/backend/src/services/pki-sync/pki-sync-queue.ts+++ b/backend/src/services/pki-sync/pki-sync-queue.ts@@ -103,6 +103,12 @@ type PkiSyncActionJob = Job<TQueuePkiSyncSyncCertificatesByIdDTO | TQueuePkiSyncImportCertificatesByIdDTO | TQueuePkiSyncRemoveCertificatesByIdDTO>;+const NON_TERMINAL_CERTIFICATE_SYNC_STATUSES = new Set<string>([+ CertificateSyncStatus.Pending,+ CertificateSyncStatus.Running,+ CertificateSyncStatus.Syncing+]);+const JITTER_MS = 10 * 1000;const HOST_SERIALISATION_LOCK_TTL_MS = 5 * 60 * 1000;@@ -248,6 +254,7 @@ export const pkiSyncQueueFactory = ({);let isSynced = false;+ let runCertificateIds: string[] = [];let certSyncFailureCount = 0;let syncMessage: string | null = null;let partialFailure = false;@@ -277,6 +284,7 @@ export const pkiSyncQueueFactory = ({if (statusUpdates.length > 0) {await certificateSyncDAL.bulkUpdateSyncStatus(statusUpdates);+ runCertificateIds = statusUpdates.map((update) => update.certificateId);}const syncResult = await PkiSyncFns.syncCertificates(pkiSyncWithCredentials, certificateMap, {@@ -377,18 +385,13 @@ export const pkiSyncQueueFactory = ({certSyncFailureCount = failedCertificateCount + (syncResult.failedRemovals ?? 0);const processedCertificateIds = new Set(Array.from(certificateMetadata.values()).map((meta) => meta.id));- const nonTerminalStatuses = new Set<string>([- CertificateSyncStatus.Pending,- CertificateSyncStatus.Running,- CertificateSyncStatus.Syncing- ]);const trackedRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);const strandedCertificateIds = trackedRecords.filter((record) =>record.certificateId &&!processedCertificateIds.has(record.certificateId) &&- nonTerminalStatuses.has(record.syncStatus ?? "")+ NON_TERMINAL_CERTIFICATE_SYNC_STATUSES.has(record.syncStatus ?? "")).map((record) => record.certificateId).filter((id): id is string => typeof id === "string");@@ -491,6 +494,16 @@ export const pkiSyncQueueFactory = ({}});+ if (!isSynced && isFinalAttempt && runCertificateIds.length > 0) {+ await certificateSyncDAL.updateSyncStatusIfIn({+ pkiSyncId: pkiSync.id,+ certificateIds: runCertificateIds,+ currentStatuses: [...NON_TERMINAL_CERTIFICATE_SYNC_STATUSES],+ status: CertificateSyncStatus.Failed,+ message: syncMessage ?? "The sync did not complete."+ });+ }+if (isSynced || isFinalAttempt) {if (!fullySynced) {let failureKind = PkiSyncFailureKind.Sync;diff --git a/backend/src/services/pki-sync/pki-sync-service.ts b/backend/src/services/pki-sync/pki-sync-service.tsindex d5f89cb043..bcc989d3a2 100644--- a/backend/src/services/pki-sync/pki-sync-service.ts+++ b/backend/src/services/pki-sync/pki-sync-service.ts@@ -329,7 +329,7 @@ export const pkiSyncServiceFactory = ({);};- const $assertTargetHostReachable = async ({+ const $assertDestinationReachable = async ({destination,connection,destinationConfig@@ -338,8 +338,10 @@ export const pkiSyncServiceFactory = ({connection: { id: string; app: AppConnection };destinationConfig: Record<string, unknown> | null | undefined;}) => {- if (connection.app !== AppConnection.LDAP) return;- if (!getPkiSyncTargetHost(destinationConfig)) return;+ const isValidatedOnSave =+ connection.app === AppConnection.PaloAltoNetworks ||+ (connection.app === AppConnection.LDAP && Boolean(getPkiSyncTargetHost(destinationConfig)));+ if (!isValidatedOnSave) return;await pkiSyncHealthCheckQueue.testTargetHostReachable({destination,@@ -749,7 +751,7 @@ export const pkiSyncServiceFactory = ({);}- await $assertTargetHostReachable({ destination, connection, destinationConfig });+ await $assertDestinationReachable({ destination, connection, destinationConfig });const encryptedCredentials =credentials?.exportPassword && !isBlankExportPassword(credentials.exportPassword)@@ -947,7 +949,7 @@ export const pkiSyncServiceFactory = ({}if (isConnectionChanging || isDestinationConfigChanging) {- await $assertTargetHostReachable({+ await $assertDestinationReachable({destination: pkiSync.destination,connection: isConnectionChanging? await resolveConnection()@@ -972,14 +974,20 @@ export const pkiSyncServiceFactory = ({resolveConnection});+ const storedFilters = pkiSync.filters as TPkiSyncFilters | null;+ const areFiltersChanging =+ filters !== undefined && JSON.stringify(filters ?? null) !== JSON.stringify(storedFilters ?? null);+if (syncOptions || destinationConfig) {- const existingCount = (await certificateSyncDAL.findByPkiSyncId(id)).length;- assertPkiSyncCertificateCapsAllowCount(- pkiSync.destination,- effectiveSyncOptions,- effectiveDestinationConfig,- existingCount- );+ if (!areFiltersChanging) {+ const existingCount = (await certificateSyncDAL.findByPkiSyncId(id)).length;+ assertPkiSyncCertificateCapsAllowCount(+ pkiSync.destination,+ effectiveSyncOptions,+ effectiveDestinationConfig,+ existingCount+ );+ }assertFiltersCannotExceedCertificateCap(pkiSync.destination,effectiveSyncOptions,@@ -1032,10 +1040,6 @@ export const pkiSyncServiceFactory = ({return pkiSync as TPkiSync;}- const storedFilters = pkiSync.filters as TPkiSyncFilters | null;- const areFiltersChanging =- filters !== undefined && JSON.stringify(filters ?? null) !== JSON.stringify(storedFilters ?? null);-if (areFiltersChanging) $assertSyncAcceptsFilters(pkiSync);if (!areFiltersChanging) {diff --git a/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt b/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txtindex 78f10c432b..062cedf999 100644--- a/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt+++ b/docs/.vale/styles/config/vocabularies/Infisical/canonical/accept.txt@@ -308,6 +308,11 @@ KempLoadMasterNetScalerCitrix+Palo Alto Networks+Alto+PAN-OS+Panorama+vsysF5BIG-IPiControldiff --git a/docs/api-reference/endpoints/app-connections/palo-alto-networks/available.mdx b/docs/api-reference/endpoints/app-connections/palo-alto-networks/available.mdxnew file mode 100644index 0000000000..b7b01e8386--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/palo-alto-networks/available.mdx@@ -0,0 +1,4 @@+---+title: "Available"+openapi: "GET /api/v1/app-connections/palo-alto-networks/available"+---diff --git a/docs/api-reference/endpoints/app-connections/palo-alto-networks/create.mdx b/docs/api-reference/endpoints/app-connections/palo-alto-networks/create.mdxnew file mode 100644index 0000000000..217988e24d--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/palo-alto-networks/create.mdx@@ -0,0 +1,10 @@+---+title: "Create"+openapi: "POST /api/v1/app-connections/palo-alto-networks"+---++<Note>+ Check out the configuration docs for [Palo Alto Networks+ Connections](/integrations/app-connections/palo-alto-networks) to learn how to obtain the+ required credentials.+</Note>diff --git a/docs/api-reference/endpoints/app-connections/palo-alto-networks/delete.mdx b/docs/api-reference/endpoints/app-connections/palo-alto-networks/delete.mdxnew file mode 100644index 0000000000..d23037d799--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/palo-alto-networks/delete.mdx@@ -0,0 +1,4 @@+---+title: "Delete"+openapi: "DELETE /api/v1/app-connections/palo-alto-networks/{connectionId}"+---diff --git a/docs/api-reference/endpoints/app-connections/palo-alto-networks/get-by-id.mdx b/docs/api-reference/endpoints/app-connections/palo-alto-networks/get-by-id.mdxnew file mode 100644index 0000000000..2410bac29c--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/palo-alto-networks/get-by-id.mdx@@ -0,0 +1,4 @@+---+title: "Get by ID"+openapi: "GET /api/v1/app-connections/palo-alto-networks/{connectionId}"+---diff --git a/docs/api-reference/endpoints/app-connections/palo-alto-networks/get-by-name.mdx b/docs/api-reference/endpoints/app-connections/palo-alto-networks/get-by-name.mdxnew file mode 100644index 0000000000..4baec67391--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/palo-alto-networks/get-by-name.mdx@@ -0,0 +1,4 @@+---+title: "Get by name"+openapi: "GET /api/v1/app-connections/palo-alto-networks/connection-name/{connectionName}"+---diff --git a/docs/api-reference/endpoints/app-connections/palo-alto-networks/list.mdx b/docs/api-reference/endpoints/app-connections/palo-alto-networks/list.mdxnew file mode 100644index 0000000000..7815f0bbd1--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/palo-alto-networks/list.mdx@@ -0,0 +1,4 @@+---+title: "List"+openapi: "GET /api/v1/app-connections/palo-alto-networks"+---diff --git a/docs/api-reference/endpoints/app-connections/palo-alto-networks/update.mdx b/docs/api-reference/endpoints/app-connections/palo-alto-networks/update.mdxnew file mode 100644index 0000000000..1a69ddaa4f--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/palo-alto-networks/update.mdx@@ -0,0 +1,10 @@+---+title: "Update"+openapi: "PATCH /api/v1/app-connections/palo-alto-networks/{connectionId}"+---++<Note>+ Check out the configuration docs for [Palo Alto Networks+ Connections](/integrations/app-connections/palo-alto-networks) to learn how to obtain the+ required credentials.+</Note>diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/create.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/create.mdxnew file mode 100644index 0000000000..2cf4b0adf2--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/create.mdx@@ -0,0 +1,4 @@+---+title: "Create Palo Alto Networks SSL/TLS Profile PKI sync"+openapi: "POST /api/v1/cert-manager/syncs/palo-alto-networks-ssl-tls-profile"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/delete.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/delete.mdxnew file mode 100644index 0000000000..00705ef3c4--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/delete.mdx@@ -0,0 +1,4 @@+---+title: "Delete Palo Alto Networks SSL/TLS Profile PKI sync"+openapi: "DELETE /api/v1/cert-manager/syncs/palo-alto-networks-ssl-tls-profile/{pkiSyncId}"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/get-by-id.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/get-by-id.mdxnew file mode 100644index 0000000000..5656e1f685--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/get-by-id.mdx@@ -0,0 +1,4 @@+---+title: "Get Palo Alto Networks SSL/TLS Profile PKI sync by ID"+openapi: "GET /api/v1/cert-manager/syncs/palo-alto-networks-ssl-tls-profile/{pkiSyncId}"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/list.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/list.mdxnew file mode 100644index 0000000000..57279d07e6--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/list.mdx@@ -0,0 +1,4 @@+---+title: "List Palo Alto Networks SSL/TLS Profile PKI syncs"+openapi: "GET /api/v1/cert-manager/syncs/palo-alto-networks-ssl-tls-profile"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/remove-certificates.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/remove-certificates.mdxnew file mode 100644index 0000000000..acf069b0b0--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/remove-certificates.mdx@@ -0,0 +1,4 @@+---+title: "Remove certificates from Palo Alto Networks SSL/TLS Profile"+openapi: "POST /api/v1/cert-manager/syncs/palo-alto-networks-ssl-tls-profile/{pkiSyncId}/remove-certificates"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/sync-certificates.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/sync-certificates.mdxnew file mode 100644index 0000000000..3723e50c1b--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/sync-certificates.mdx@@ -0,0 +1,4 @@+---+title: "Sync certificates to Palo Alto Networks SSL/TLS Profile"+openapi: "POST /api/v1/cert-manager/syncs/palo-alto-networks-ssl-tls-profile/{pkiSyncId}/sync"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/update.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/update.mdxnew file mode 100644index 0000000000..2019473825--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/update.mdx@@ -0,0 +1,4 @@+---+title: "Update Palo Alto Networks SSL/TLS Profile PKI sync"+openapi: "PATCH /api/v1/cert-manager/syncs/palo-alto-networks-ssl-tls-profile/{pkiSyncId}"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/create.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/create.mdxnew file mode 100644index 0000000000..d66a5c5d53--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/create.mdx@@ -0,0 +1,4 @@+---+title: "Create Palo Alto Networks PKI sync"+openapi: "POST /api/v1/cert-manager/syncs/palo-alto-networks"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/delete.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/delete.mdxnew file mode 100644index 0000000000..437dd95da7--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/delete.mdx@@ -0,0 +1,4 @@+---+title: "Delete Palo Alto Networks PKI sync"+openapi: "DELETE /api/v1/cert-manager/syncs/palo-alto-networks/{pkiSyncId}"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/get-by-id.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/get-by-id.mdxnew file mode 100644index 0000000000..10d5c82b22--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/get-by-id.mdx@@ -0,0 +1,4 @@+---+title: "Get Palo Alto Networks PKI sync by ID"+openapi: "GET /api/v1/cert-manager/syncs/palo-alto-networks/{pkiSyncId}"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/list.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/list.mdxnew file mode 100644index 0000000000..20c019eb36--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/list.mdx@@ -0,0 +1,4 @@+---+title: "List Palo Alto Networks PKI syncs"+openapi: "GET /api/v1/cert-manager/syncs/palo-alto-networks"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/remove-certificates.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/remove-certificates.mdxnew file mode 100644index 0000000000..6fc94362a0--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/remove-certificates.mdx@@ -0,0 +1,4 @@+---+title: "Remove certificates from Palo Alto Networks"+openapi: "POST /api/v1/cert-manager/syncs/palo-alto-networks/{pkiSyncId}/remove-certificates"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/sync-certificates.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/sync-certificates.mdxnew file mode 100644index 0000000000..c43434cdbf--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/sync-certificates.mdx@@ -0,0 +1,4 @@+---+title: "Sync certificates to Palo Alto Networks"+openapi: "POST /api/v1/cert-manager/syncs/palo-alto-networks/{pkiSyncId}/sync"+---diff --git a/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/update.mdx b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/update.mdxnew file mode 100644index 0000000000..f9215ce381--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/palo-alto-networks/update.mdx@@ -0,0 +1,4 @@+---+title: "Update Palo Alto Networks PKI sync"+openapi: "PATCH /api/v1/cert-manager/syncs/palo-alto-networks/{pkiSyncId}"+---diff --git a/docs/docs.json b/docs/docs.jsonindex 76913891be..a0960531f7 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -568,6 +568,8 @@"documentation/platform/pki/applications/certificate-syncs/cloudflare-custom-certificate","documentation/platform/pki/applications/certificate-syncs/f5-big-ip","documentation/platform/pki/applications/certificate-syncs/netscaler",+ "documentation/platform/pki/applications/certificate-syncs/palo-alto-networks",+ "documentation/platform/pki/applications/certificate-syncs/palo-alto-networks-ssl-tls-profile","documentation/platform/pki/applications/certificate-syncs/kemp-loadmaster","documentation/platform/pki/applications/certificate-syncs/linux-server","documentation/platform/pki/applications/certificate-syncs/windows-server",@@ -1118,6 +1120,7 @@"integrations/app-connections/openrouter","integrations/app-connections/oracledb","integrations/app-connections/ovh",+ "integrations/app-connections/palo-alto-networks","integrations/app-connections/postgres","integrations/app-connections/powerdns","integrations/app-connections/qovery",@@ -2326,6 +2329,18 @@"api-reference/endpoints/app-connections/ovh/create"]},+ {+ "group": "Palo Alto Networks",+ "pages": [+ "api-reference/endpoints/app-connections/palo-alto-networks/list",+ "api-reference/endpoints/app-connections/palo-alto-networks/available",+ "api-reference/endpoints/app-connections/palo-alto-networks/get-by-id",+ "api-reference/endpoints/app-connections/palo-alto-networks/get-by-name",+ "api-reference/endpoints/app-connections/palo-alto-networks/create",+ "api-reference/endpoints/app-connections/palo-alto-networks/update",+ "api-reference/endpoints/app-connections/palo-alto-networks/delete"+ ]+ },{"group": "PostgreSQL","pages": [@@ -4111,6 +4126,30 @@"api-reference/endpoints/pki/syncs/netscaler/remove-certificates"]},+ {+ "group": "Palo Alto Networks",+ "pages": [+ "api-reference/endpoints/pki/syncs/palo-alto-networks/list",+ "api-reference/endpoints/pki/syncs/palo-alto-networks/get-by-id",+ "api-reference/endpoints/pki/syncs/palo-alto-networks/create",+ "api-reference/endpoints/pki/syncs/palo-alto-networks/update",+ "api-reference/endpoints/pki/syncs/palo-alto-networks/delete",+ "api-reference/endpoints/pki/syncs/palo-alto-networks/sync-certificates",+ "api-reference/endpoints/pki/syncs/palo-alto-networks/remove-certificates"+ ]+ },+ {+ "group": "Palo Alto Networks SSL/TLS Profile",+ "pages": [+ "api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/list",+ "api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/get-by-id",+ "api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/create",+ "api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/update",+ "api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/delete",+ "api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/sync-certificates",+ "api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/remove-certificates"+ ]+ },{"group": "Linux Server","pages": [diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/nutanix-prism-central.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/nutanix-prism-central.mdxindex a684cdfcc5..68a9a44629 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/nutanix-prism-central.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/nutanix-prism-central.mdx@@ -37,7 +37,7 @@ Before setting up the sync, gather the following from your Nutanix environment:- **Name**: A name for this sync.- **Description**: Optional description.- 6. Select the certificate to sync.+ 6. Select the **Certificate Order** to sync. A certificate order is a certificate together with its renewals.7. Review and click **Create Sync**.</Tab>diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/overview.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/overview.mdxindex 50d37e67e2..ca938c3ac1 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/overview.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/overview.mdx@@ -83,6 +83,12 @@ flowchart LR<Card title="NetScaler" icon="server" href="/documentation/platform/pki/applications/certificate-syncs/netscaler">Deploy certificates to Citrix NetScaler ADC.</Card>+ <Card title="Palo Alto Networks" icon="shield" href="/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks">+ Deploy certificates to PAN-OS firewalls and Panorama templates.+ </Card>+ <Card title="Palo Alto Networks SSL/TLS profile" icon="shield" href="/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks-ssl-tls-profile">+ Point a PAN-OS SSL/TLS service profile at a synced certificate.+ </Card><Card title="Kemp LoadMaster" icon="scale" href="/documentation/platform/pki/applications/certificate-syncs/kemp-loadmaster">Deploy certificates to Progress Kemp LoadMaster.</Card>diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks-ssl-tls-profile.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks-ssl-tls-profile.mdxnew file mode 100644index 0000000000..ef84b5accd--- /dev/null+++ b/docs/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks-ssl-tls-profile.mdx@@ -0,0 +1,183 @@+---+title: "Palo Alto Networks SSL/TLS profile"+sidebarTitle: "Palo Alto Networks SSL/TLS profile"+description: "Deploy a certificate to a PAN-OS firewall or Panorama template and point an SSL/TLS service profile at it."+---++A Palo Alto Networks SSL/TLS Profile sync deploys one certificate to a PAN-OS firewall or a Panorama template, then points an existing SSL/TLS service profile at that certificate. Use this sync for a service that reads its certificate from an SSL/TLS service profile, such as the management web interface or a GlobalProtect portal.++To deploy several certificates without changing a profile, use a [Palo Alto Networks sync](/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks) instead.++## Prerequisites++- An [application](/documentation/platform/pki/applications/overview) that holds the certificate to deploy+- A [Palo Alto Networks connection](/integrations/app-connections/palo-alto-networks) to the firewall or Panorama+- On a Panorama, a template. To push to firewalls, the template must belong to at least one template stack+- An SSL/TLS service profile on the firewall or in the template, either shared or in a virtual system++## Create a sync++<Tabs>+ <Tab title="Infisical UI">+ <Steps>+ <Step>+ In your application, open the **Certificate Syncs** tab and select **Add Sync**.+ </Step>+ <Step>+ Select **Palo Alto Networks SSL/TLS Profile**.+ </Step>+ <Step>+ Configure the destination, then select **Continue**:++ - **Palo Alto Networks Connection**: the connection to the firewall or Panorama+ - **Template** (Panorama only): the template to import the certificate into+ - **SSL/TLS Service Profile**: the profile to point at the synced certificate+ - **Push to Devices** (Panorama only): whether the sync pushes the committed changes to firewalls (on by default)+ </Step>+ <Step>+ Configure the sync options, then select **Continue**:++ - **Allow to remove certificates from destination**: delete the old certificate from the device when it's replaced or no longer active in Infisical+ - **Preserve certificate on renewal**: replace the certificate in place when it's renewed (see [Certificate renewal](#certificate-renewal))+ - **Certificate name schema**: the name of the certificate object on the device, up to 31 characters (use `{{shortCertificateId}}` rather than `{{certificateId}}`, which is too long)+ - **Auto-sync on change**: sync the certificate as soon as it's issued or renewed+ </Step>+ <Step>+ Enter a **Name** and an optional **Description** for the sync, then select **Continue**.+ </Step>+ <Step>+ Select the **Certificate Order** the sync holds, then select **Continue**. A certificate order is a certificate together with its renewals.+ </Step>+ <Step>+ Review the configuration and select **Create Sync**.+ </Step>+ </Steps>+ </Tab>+ <Tab title="API">+ To create a Palo Alto Networks SSL/TLS Profile sync, make an API request to the [Create Palo Alto Networks SSL/TLS Profile PKI sync](/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/create) endpoint.++ In `destinationConfig`, set `sslTlsServiceProfileName` to the name of the profile. If the profile belongs to a virtual system, also set `sslTlsServiceProfileVsys`, such as `vsys1`. Leave `sslTlsServiceProfileVsys` out for a shared profile.++ <Note>+ Pass `filters` to describe the certificate this sync holds. The filters must match a single certificate or certificate order. If you omit `filters`, the sync starts empty and you can set filters later.+ See [Certificate filters](/documentation/platform/pki/applications/certificate-syncs/overview#certificate-filters).+ </Note>++ ### Sample request++ ```bash Request+ curl --request POST \+ --url https://app.infisical.com/api/v1/cert-manager/syncs/palo-alto-networks-ssl-tls-profile \+ --header 'Authorization: Bearer <access-token>' \+ --header 'Content-Type: application/json' \+ --data '{+ "name": "gp-portal-cert-sync",+ "applicationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "description": "GlobalProtect portal certificate",+ "connectionId": "550e8400-e29b-41d4-a716-446655440000",+ "isAutoSyncEnabled": true,+ "filters": {+ "certificateOrderIds": ["550e8400-e29b-41d4-a716-446655440000"]+ },+ "syncOptions": {+ "canRemoveCertificates": true,+ "preserveItemOnRenewal": true,+ "certificateNameSchema": "INF-{{shortCertificateId}}"+ },+ "destinationConfig": {+ "template": "branch-template",+ "pushToDevices": true,+ "sslTlsServiceProfileName": "gp-portal-profile",+ "sslTlsServiceProfileVsys": "vsys1"+ }+ }'+ ```++ ### Sample response++ ```json Response expandable+ {+ "pkiSync": {+ "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "name": "gp-portal-cert-sync",+ "description": "GlobalProtect portal certificate",+ "destination": "palo-alto-networks-ssl-tls-profile",+ "isAutoSyncEnabled": true,+ "destinationConfig": {+ "template": "branch-template",+ "pushToDevices": true,+ "sslTlsServiceProfileName": "gp-portal-profile",+ "sslTlsServiceProfileVsys": "vsys1"+ },+ "syncOptions": {+ "canRemoveCertificates": true,+ "preserveItemOnRenewal": true,+ "certificateNameSchema": "INF-{{shortCertificateId}}"+ },+ "applicationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "connectionId": "550e8400-e29b-41d4-a716-446655440000",+ "createdAt": "2026-10-08T00:00:00.000Z",+ "updatedAt": "2026-10-08T00:00:00.000Z"+ }+ }+ ```+ </Tab>+</Tabs>++## How it works++Each time it runs, the sync imports the certificate the same way a [Palo Alto Networks sync](/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks#how-it-works) does, then points the SSL/TLS service profile at it. The sync doesn't create the profile or change its other settings.++## Certificate renewal++When the certificate is renewed, the result depends on **Preserve certificate on renewal**:++- **On (default)**: the sync replaces the certificate object in place, so the profile keeps using it+- **Off**: the sync creates a new certificate object, points the profile at it, and deletes the old one only if **Allow to remove certificates from destination** is on++## Removing the certificate++PAN-OS doesn't let the sync delete the certificate while the profile uses it. If you change the sync's certificate order, the sync points the profile at the new certificate before it deletes the old one.++To remove the certificate without replacing it:++<Steps>+ <Step>+ On the device, point the SSL/TLS service profile at another certificate, then commit the change.+ </Step>+ <Step>+ Use the [Remove certificates from Palo Alto Networks SSL/TLS Profile](/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/remove-certificates) endpoint.+ </Step>+</Steps>++## Manual sync++To sync on demand, use the [Sync certificates to Palo Alto Networks SSL/TLS Profile](/api-reference/endpoints/pki/syncs/palo-alto-networks-ssl-tls-profile/sync-certificates) endpoint.++## FAQ++<AccordionGroup>+ <Accordion title="Why can this sync hold only one certificate?">+ An SSL/TLS service profile uses one certificate at a time. To deploy more certificates to the same device, create a [Palo Alto Networks sync](/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks).+ </Accordion>+ <Accordion title="Can I point several profiles at the same certificate?">+ Yes. Each sync updates one profile, so create one sync for each profile.+ </Accordion>+</AccordionGroup>++## Next steps++<CardGroup cols={2}>+ <Card title="Palo Alto Networks" icon="shield" href="/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks">+ Deploy certificates to the certificate store without changing a profile.+ </Card>+ <Card title="Renewal" icon="rotate-cw" href="/documentation/platform/pki/applications/certificate-renewal">+ Renew a certificate, and change its details as part of the renewal.+ </Card>+ <Card title="Alerting" icon="bell" href="/documentation/platform/pki/applications/alerting/overview">+ Get notified about certificate lifecycle events.+ </Card>+ <Card title="Certificate syncs" icon="refresh-cw" href="/documentation/platform/pki/applications/certificate-syncs/overview">+ View all supported sync destinations.+ </Card>+</CardGroup>diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks.mdxnew file mode 100644index 0000000000..2c5f781212--- /dev/null+++ b/docs/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks.mdx@@ -0,0 +1,172 @@+---+title: "Palo Alto Networks"+sidebarTitle: "Palo Alto Networks"+description: "Deploy certificates to the certificate store of PAN-OS firewalls and Panorama templates."+---++A Palo Alto Networks sync imports certificates and their private keys into the certificate store of a PAN-OS firewall or a Panorama template, then commits the change.++If a service on the device needs to use the certificate, such as the management web interface or a GlobalProtect portal, use a [Palo Alto Networks SSL/TLS Profile sync](/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks-ssl-tls-profile) instead. That sync also points an SSL/TLS service profile at the certificate.++## Prerequisites++- An [application](/documentation/platform/pki/applications/overview) that holds the certificates to deploy+- A [Palo Alto Networks connection](/integrations/app-connections/palo-alto-networks) to the firewall or Panorama+- On a Panorama, a template. To push to firewalls, the template must belong to at least one template stack++## Create a sync++<Tabs>+ <Tab title="Infisical UI">+ <Steps>+ <Step>+ In your application, open the **Certificate Syncs** tab and select **Add Sync**.+ </Step>+ <Step>+ Select **Palo Alto Networks**.+ </Step>+ <Step>+ Configure the destination, then select **Continue**:++ - **Palo Alto Networks Connection**: the connection to the firewall or Panorama+ - **Template** (Panorama only): the template to import the certificates into+ - **Push to Devices** (Panorama only): whether the sync pushes the committed changes to firewalls (on by default)+ </Step>+ <Step>+ Configure the sync options, then select **Continue**:++ - **Allow to remove certificates from destination**: delete a certificate from the device when it's no longer active in Infisical+ - **Preserve certificate on renewal**: replace the certificate in place when it's renewed (see [Certificate renewal](#certificate-renewal))+ - **Certificate name schema**: the name of each certificate object on the device, up to 31 characters (use `{{shortCertificateId}}` rather than `{{certificateId}}`, which is too long; see [Certificate name schema](/documentation/platform/pki/applications/certificate-syncs/overview#certificate-name-schema))+ - **Auto-sync on change**: sync certificates as soon as they're issued or renewed+ </Step>+ <Step>+ Enter a **Name** and an optional **Description** for the sync, then select **Continue**.+ </Step>+ <Step>+ Select which certificates the sync holds, then select **Continue**.+ </Step>+ <Step>+ Review the configuration and select **Create Sync**.+ </Step>+ </Steps>+ </Tab>+ <Tab title="API">+ To create a Palo Alto Networks sync, make an API request to the [Create Palo Alto Networks PKI sync](/api-reference/endpoints/pki/syncs/palo-alto-networks/create) endpoint.++ <Note>+ Pass `filters` to describe the certificates this sync holds. If a certificate in the application matches the filters, it's attached to the sync as soon as it's issued. If you omit `filters`, the sync starts empty and you can set filters later.+ See [Certificate filters](/documentation/platform/pki/applications/certificate-syncs/overview#certificate-filters).+ </Note>++ ### Sample request++ ```bash Request+ curl --request POST \+ --url https://app.infisical.com/api/v1/cert-manager/syncs/palo-alto-networks \+ --header 'Authorization: Bearer <access-token>' \+ --header 'Content-Type: application/json' \+ --data '{+ "name": "my-panorama-cert-sync",+ "applicationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "description": "Branch firewall certificates",+ "connectionId": "550e8400-e29b-41d4-a716-446655440000",+ "isAutoSyncEnabled": true,+ "filters": {+ "certificateOrderIds": ["550e8400-e29b-41d4-a716-446655440000"]+ },+ "syncOptions": {+ "canRemoveCertificates": true,+ "preserveItemOnRenewal": true,+ "certificateNameSchema": "INF-{{shortCertificateId}}"+ },+ "destinationConfig": {+ "template": "branch-template",+ "pushToDevices": true+ }+ }'+ ```++ ### Sample response++ ```json Response+ {+ "pkiSync": {+ "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "name": "my-panorama-cert-sync",+ "description": "Branch firewall certificates",+ "destination": "palo-alto-networks",+ "isAutoSyncEnabled": true,+ "destinationConfig": {+ "template": "branch-template",+ "pushToDevices": true+ },+ "syncOptions": {+ "canRemoveCertificates": true,+ "preserveItemOnRenewal": true,+ "certificateNameSchema": "INF-{{shortCertificateId}}"+ },+ "applicationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "connectionId": "550e8400-e29b-41d4-a716-446655440000",+ "createdAt": "2026-10-08T00:00:00.000Z",+ "updatedAt": "2026-10-08T00:00:00.000Z"+ }+ }+ ```+ </Tab>+</Tabs>++## How it works++Each time it runs, the sync:++- Imports each certificate and its private key into the shared certificate store of the firewall, or of the selected template on a Panorama+- Imports the issuing CA certificates as separate objects named `INF-CA-<fingerprint>`, skipping any already on the device+- Commits only the changes made by the connection's administrator account, so pending changes from other administrators stay uncommitted+- On a Panorama with **Push to Devices** on, pushes every template stack that contains the template to its firewalls++<Note>+ A push also sends changes that other administrators committed on Panorama for those template stacks but haven't pushed yet. To push on your own schedule, turn off **Push to Devices**.+</Note>++## Certificate renewal++When a certificate is renewed, the result depends on **Preserve certificate on renewal**:++- **On (default)**: the sync replaces the certificate object in place, so anything that references it by name uses the renewed certificate+- **Off**: the sync creates a new certificate object, and deletes the old one only if **Allow to remove certificates from destination** is on++## Removing certificates++If **Allow to remove certificates from destination** is on, the sync deletes the certificate object of a certificate that's no longer active in Infisical. The CA certificate objects stay on the device.++PAN-OS doesn't delete a certificate that's still in use, such as by an SSL/TLS service profile. If that happens, the sync shows the PAN-OS error. Remove the reference on the device, then sync again.++## Manual sync++To remove certificates on demand, use the [Remove certificates from Palo Alto Networks](/api-reference/endpoints/pki/syncs/palo-alto-networks/remove-certificates) endpoint. To sync on demand, use the [Sync certificates to Palo Alto Networks](/api-reference/endpoints/pki/syncs/palo-alto-networks/sync-certificates) endpoint.++## FAQ++<AccordionGroup>+ <Accordion title="Can I import certificates from a Palo Alto Networks device into Infisical?">+ No. Palo Alto Networks syncs only deploy certificates from Infisical to the device.+ </Accordion>+</AccordionGroup>++## Next steps++<CardGroup cols={2}>+ <Card title="Palo Alto Networks SSL/TLS profile" icon="lock" href="/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks-ssl-tls-profile">+ Point an SSL/TLS service profile at a synced certificate.+ </Card>+ <Card title="Renewal" icon="rotate-cw" href="/documentation/platform/pki/applications/certificate-renewal">+ Renew a certificate, and change its details as part of the renewal.+ </Card>+ <Card title="Alerting" icon="bell" href="/documentation/platform/pki/applications/alerting/overview">+ Get notified about certificate lifecycle events.+ </Card>+ <Card title="Certificate syncs" icon="refresh-cw" href="/documentation/platform/pki/applications/certificate-syncs/overview">+ View all supported sync destinations.+ </Card>+</CardGroup>diff --git a/docs/integrations/app-connections/palo-alto-networks.mdx b/docs/integrations/app-connections/palo-alto-networks.mdxnew file mode 100644index 0000000000..2de0b27503--- /dev/null+++ b/docs/integrations/app-connections/palo-alto-networks.mdx@@ -0,0 +1,95 @@+---+title: "Palo Alto Networks connection"+sidebarTitle: "Palo Alto Networks"+description: "Learn how to configure a Palo Alto Networks connection for Infisical."+---++A Palo Alto Networks connection authenticates Infisical to a PAN-OS firewall or a Panorama with the username and password of a PAN-OS administrator, so [Palo Alto Networks certificate syncs](/documentation/platform/pki/applications/certificate-syncs/overview) can import certificates and commit the changes. The same connection form works for both device types, and each sync detects whether the device is a firewall or a Panorama.++<Note>+ This guide only authenticates Infisical with your Palo Alto Networks device. Once the app connection is ready, you can [use it to set up integrations](#step-3-configure-integrations).+</Note>++## Prerequisites++- A PAN-OS administrator account with the **Superuser** role on the firewall or Panorama, so you can create an Admin Role profile and another administrator+- Network access from Infisical to the device's management interface over HTTPS, either directly or through an [Infisical Gateway](/documentation/platform/gateways/overview)++## Step 1: Create a dedicated PAN-OS administrator++The connection signs in as a PAN-OS administrator that can use the XML API. Create a dedicated account for it, because each sync commits every pending change made with that account, including a person's unfinished edits.++<Steps>+ <Step>+ In the PAN-OS web interface, go to **Device** > **Admin Roles** and select **Add**. On a Panorama, go to **Panorama** > **Admin Roles** instead.+ </Step>+ <Step>+ Enter a **Name** for the profile. On the **XML API** tab, enable only **Configuration**, **Operational Requests**, **Commit**, and **Import**.+ </Step>+ <Step>+ On the **Web UI** and **REST API** tabs, disable every item, because the connection uses neither one. Then select **OK**.+ </Step>+ <Step>+ Go to **Device** > **Administrators** (or **Panorama** > **Administrators** on a Panorama) and select **Add**.+ </Step>+ <Step>+ Enter a **Name** and **Password** for the account. Set **Administrator Type** to **Role Based** and select the Admin Role profile you created as the **Profile**. Then select **OK**.+ </Step>+ <Step>+ Commit the changes.+ </Step>+</Steps>++## Step 2: Create the app connection++Next, create the app connection in Infisical.++<Tip>+ To create the connection using the API, use the [Create Palo Alto Networks Connection](/api-reference/endpoints/app-connections/palo-alto-networks/create) endpoint.+</Tip>++<Steps>+ <Step>+ In Certificate Manager, go to **Settings** > **App Connections** and select **Add Connection**.+ </Step>+ <Step>+ Select **Palo Alto Networks**.+ </Step>+ <Step>+ Fill out the form's fields:++ - **Name**: a name for the connection+ - **Description** (optional): a description of the connection+ - **Gateway** (optional): the [Infisical Gateway](/documentation/platform/gateways/overview) to connect through, if the device is on a private network+ - **Hostname**: the IP address or hostname of the device's management interface, such as `firewall.example.com`+ - **Username**: the username of the administrator from [Step 1](#step-1-create-a-dedicated-pan-os-administrator)+ - **Password**: the password of that administrator+ - **Port** (optional): the HTTPS port of the management interface (defaults to `443`)+ </Step>+ <Step>+ On the **SSL** tab, set how the connection verifies the TLS certificate of the management interface. PAN-OS uses a self-signed certificate for the management interface by default, so do one of the following:++ - Paste the certificate of the CA that issued the management interface certificate, in PEM format, into **SSL Certificate**+ - Turn off **Reject Unauthorized** to skip verification+ </Step>+ <Step>+ Select **Connect to Palo Alto Networks**.+ </Step>+</Steps>++<Check>+ Your Palo Alto Networks app connection is ready to use.+</Check>++## Step 3: Configure integrations++Now that your Palo Alto Networks app connection is configured, you can use it to set up the following integrations:++<CardGroup cols={2}>+ <Card title="Palo Alto Networks" icon="refresh-cw" href="/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks">+ Deploy certificates to PAN-OS firewalls and Panorama templates.+ </Card>+ <Card title="Palo Alto Networks SSL/TLS profile" icon="refresh-cw" href="/documentation/platform/pki/applications/certificate-syncs/palo-alto-networks-ssl-tls-profile">+ Point a PAN-OS SSL/TLS service profile at a synced certificate.+ </Card>+</CardGroup>diff --git a/docs/snippets/catalogs/app-connections.jsx b/docs/snippets/catalogs/app-connections.jsxindex 6677b2c5c1..0630b73832 100644--- a/docs/snippets/catalogs/app-connections.jsx+++ b/docs/snippets/catalogs/app-connections.jsx@@ -599,6 +599,14 @@ export const appConnections = ["Learn how to connect NetScaler to deploy and manage certificates with Infisical.",category: "Networking & DNS",},+ {+ name: "Palo Alto Networks",+ slug: "palo-alto-networks",+ path: "/integrations/app-connections/palo-alto-networks",+ description:+ "Learn how to connect Palo Alto Networks firewalls and Panorama to deploy certificates with Infisical.",+ category: "Networking & DNS",+ },{name: "GoDaddy",slug: "godaddy",diff --git a/frontend/public/images/integrations/Palo Alto Networks.png b/frontend/public/images/integrations/Palo Alto Networks.pngnew file mode 100644index 0000000000..471d25ef46Binary files /dev/null and b/frontend/public/images/integrations/Palo Alto Networks.png differdiff --git a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsxindex 5cf284e21c..306a045410 100644--- a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx+++ b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx@@ -27,11 +27,13 @@ import {} from "@app/components/v3";import { useProject } from "@app/context";import {+ isPaloAltoNetworksPkiSync,PKI_SYNC_MAP,PRESERVE_ARN_DESTINATIONS,PRESERVE_ITEM_ON_RENEWAL_DESTINATIONS} from "@app/helpers/pkiSyncs";import { AppConnection } from "@app/hooks/api/appConnections/enums";+import { usePaloAltoNetworksConnectionListTemplates } from "@app/hooks/api/appConnections/palo-alto-networks";import {PkiSync,PkiSyncExportFormat,@@ -43,6 +45,10 @@ import {} from "@app/hooks/api/pkiSyncs";import { KEMP_DEFAULT_CA_NAME_SCHEMA } from "./schemas/kemp-loadmaster-pki-sync-destination-schema";+import {+ isPaloAltoNetworksTemplateMissing,+ PALO_ALTO_NETWORKS_TEMPLATE_REQUIRED_MESSAGE+} from "./schemas/palo-alto-networks-pki-sync-destination-schema";import {getKeystoreFieldIssues,PkiSyncFormSchema,@@ -283,6 +289,10 @@ export const CreatePkiSyncForm = ({const { handleSubmit, trigger, control, getValues, setError, watch } = formMethods;const canRemoveCertificates = watch("syncOptions.canRemoveCertificates");+ const { data: paloAltoNetworksDevice, isLoading: isDetectingPaloAltoNetworksDevice } =+ usePaloAltoNetworksConnectionListTemplates(watch("connection.id"), {+ enabled: isPaloAltoNetworksPkiSync(destination)+ });const isStepValid = async (index: number) => {const isValid = await trigger(FORM_TABS[index].fields);@@ -301,6 +311,21 @@ export const CreatePkiSyncForm = ({}}+ if (+ FORM_TABS[index].key === "destination" &&+ isPaloAltoNetworksPkiSync(destination) &&+ isPaloAltoNetworksTemplateMissing(+ paloAltoNetworksDevice?.isPanorama,+ getValues("destinationConfig")+ )+ ) {+ setError("destinationConfig.template" as FieldPath<TPkiSyncForm>, {+ type: "manual",+ message: PALO_ALTO_NETWORKS_TEMPLATE_REQUIRED_MESSAGE+ });+ return false;+ }+if (FORM_TABS[index].key === "options") {const issues = getKeystoreFieldIssues(getValues(), { requirePassword: true });issues.forEach(({ path, message }) =>@@ -323,6 +348,7 @@ export const CreatePkiSyncForm = ({};const isFinalStep = selectedTabIndex === FORM_TABS.length - 1;+ const isNextBusy = (isFinalStep && createPkiSync.isPending) || isDetectingPaloAltoNetworksDevice;const handleNext = async () => {if (isFinalStep) {@@ -473,7 +499,7 @@ export const CreatePkiSyncForm = ({variant="project"onClick={handleNext}isPending={isFinalStep && createPkiSync.isPending}- isDisabled={isFinalStep && createPkiSync.isPending}+ isDisabled={isNextBusy}>{isFinalStep ? "Create Sync" : "Continue"}</Button>diff --git a/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsxindex 65d3fabd11..eb978a7b49 100644--- a/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx+++ b/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx@@ -1,5 +1,5 @@import { useEffect, useState } from "react";-import { Controller, FormProvider, useForm } from "react-hook-form";+import { Controller, FieldPath, FormProvider, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { AlertTriangleIcon } from "lucide-react";@@ -25,8 +25,13 @@ import {StepperStep,Toggle} from "@app/components/v3";-import { getCertificateDisplayName, PKI_SYNC_MAP } from "@app/helpers/pkiSyncs";+import {+ getCertificateDisplayName,+ isPaloAltoNetworksPkiSync,+ PKI_SYNC_MAP+} from "@app/helpers/pkiSyncs";import { AppConnection } from "@app/hooks/api/appConnections/enums";+import { usePaloAltoNetworksConnectionListTemplates } from "@app/hooks/api/appConnections/palo-alto-networks";import {PkiSync,TPkiSync,@@ -38,6 +43,10 @@ import {} from "@app/hooks/api/pkiSyncs";import { TPkiSyncFilterPreview } from "@app/hooks/api/pkiSyncs/types";+import {+ isPaloAltoNetworksTemplateMissing,+ PALO_ALTO_NETWORKS_TEMPLATE_REQUIRED_MESSAGE+} from "./schemas/palo-alto-networks-pki-sync-destination-schema";import {removeUnusedKeystoreOptions,TUpdatePkiSyncForm,@@ -233,8 +242,14 @@ export const EditPkiSyncForm = ({const {handleSubmit,control,+ getValues,+ setError,formState: { isSubmitting, isDirty }} = formMethods;+ const { data: paloAltoNetworksDevice, isLoading: isDetectingPaloAltoNetworksDevice } =+ usePaloAltoNetworksConnectionListTemplates(formMethods.watch("connection.id"), {+ enabled: isPaloAltoNetworksPkiSync(pkiSync.destination)+ });const previewFilters = usePreviewPkiSyncFilters();const [pendingUnlink, setPendingUnlink] = useState<{@@ -271,6 +286,21 @@ export const EditPkiSyncForm = ({};const onSubmit = async (formData: TUpdatePkiSyncForm) => {+ if (+ isPaloAltoNetworksPkiSync(pkiSync.destination) &&+ isPaloAltoNetworksTemplateMissing(+ paloAltoNetworksDevice?.isPanorama,+ getValues("destinationConfig")+ )+ ) {+ setError("destinationConfig.template" as FieldPath<TUpdatePkiSyncForm>, {+ type: "manual",+ message: PALO_ALTO_NETWORKS_TEMPLATE_REQUIRED_MESSAGE+ });+ setSelectedStepIndex(steps.findIndex((step) => step.key === "destination"));+ return;+ }+const haveFiltersChanged =JSON.stringify(formData.filters ?? null) !== JSON.stringify(pkiSync.filters ?? null);@@ -422,7 +452,7 @@ export const EditPkiSyncForm = ({variant="project"type="submit"isPending={isSubmitting}- isDisabled={!isDirty || isSubmitting}+ isDisabled={!isDirty || isSubmitting || isDetectingPaloAltoNetworksDevice}>Save</Button>diff --git a/frontend/src/components/pki-syncs/forms/PaloAltoNetworksPkiSyncFields.tsx b/frontend/src/components/pki-syncs/forms/PaloAltoNetworksPkiSyncFields.tsxnew file mode 100644index 0000000000..c2f00e26f5--- /dev/null+++ b/frontend/src/components/pki-syncs/forms/PaloAltoNetworksPkiSyncFields.tsx@@ -0,0 +1,227 @@+import { useEffect } from "react";+import { Controller, useFormContext, useFormState, useWatch } from "react-hook-form";+import { AxiosError } from "axios";+import { Info } from "lucide-react";++import {+ Field,+ FieldContent,+ FieldDescription,+ FieldError,+ FieldLabel,+ FilterableSelect,+ Label,+ Toggle,+ Tooltip,+ TooltipContent,+ TooltipTrigger+} from "@app/components/v3";+import { getPaloAltoNetworksProfileLabel } from "@app/helpers/pkiSyncs";+import {+ TPaloAltoNetworksSslTlsServiceProfile,+ usePaloAltoNetworksConnectionListSslTlsServiceProfiles,+ usePaloAltoNetworksConnectionListTemplates+} from "@app/hooks/api/appConnections/palo-alto-networks";+import { PkiSync } from "@app/hooks/api/pkiSyncs";++import { TPkiSyncForm } from "./schemas/pki-sync-schema";+import { PkiSyncConnectionField } from "./PkiSyncConnectionField";++type TPaloAltoNetworksForm = TPkiSyncForm & { destination: PkiSync.PaloAltoNetworksSslTlsProfile };++const getProfileValue = (profile: TPaloAltoNetworksSslTlsServiceProfile) =>+ `${profile.name}:${profile.vsys ?? ""}`;++const getFetchErrorMessage = (error: unknown, fallback: string) =>+ (error as AxiosError<{ message?: string }>)?.response?.data?.message ?? fallback;++export const PaloAltoNetworksPkiSyncFields = ({+ withSslTlsServiceProfile = false+}: {+ withSslTlsServiceProfile?: boolean;+}) => {+ const { control, setValue, clearErrors, getFieldState } = useFormContext<TPaloAltoNetworksForm>();++ const connectionId = useWatch({ name: "connection.id", control });+ const template = useWatch({ name: "destinationConfig.template", control });+ const profileName = useWatch({ name: "destinationConfig.sslTlsServiceProfileName", control });+ const profileVsys = useWatch({ name: "destinationConfig.sslTlsServiceProfileVsys", control });+ const profileNameError = getFieldState(+ "destinationConfig.sslTlsServiceProfileName",+ useFormState({ control, name: "destinationConfig.sslTlsServiceProfileName" })+ ).error;++ const {+ data: templatesData,+ isLoading: isDetectingDevice,+ isError: isTemplatesError,+ error: templatesError+ } = usePaloAltoNetworksConnectionListTemplates(connectionId);++ const isPanorama = Boolean(templatesData?.isPanorama);+ const templates = templatesData?.templates ?? [];++ const isProfileSelectReady = Boolean(templatesData) && (!isPanorama || Boolean(template));++ const {+ data: profiles = [],+ isFetching: isLoadingProfiles,+ isError: isProfilesError,+ error: profilesError+ } = usePaloAltoNetworksConnectionListSslTlsServiceProfiles(connectionId, template, {+ enabled: withSslTlsServiceProfile && isProfileSelectReady+ });++ useEffect(() => {+ if (templatesData && !templatesData.isPanorama && template) {+ setValue("destinationConfig.template", "", { shouldDirty: true });+ }+ }, [templatesData, template]);++ const clearProfile = () => {+ setValue("destinationConfig.sslTlsServiceProfileName", "", { shouldDirty: true });+ setValue("destinationConfig.sslTlsServiceProfileVsys", "", { shouldDirty: true });+ clearErrors("destinationConfig.sslTlsServiceProfileName");+ };++ let profilePlaceholder = "Select an SSL/TLS service profile";+ if (!connectionId) profilePlaceholder = "Select a connection first";+ else if (isDetectingDevice) profilePlaceholder = "Detecting device type...";+ else if (isPanorama && !template) profilePlaceholder = "Select a template first";++ const deviceError =+ connectionId && isTemplatesError+ ? {+ message: getFetchErrorMessage(+ templatesError,+ "Failed to read the device. Check the connection settings."+ )+ }+ : undefined;++ const profileError =+ profileNameError ??+ (connectionId && isProfilesError+ ? {+ message: getFetchErrorMessage(+ profilesError,+ "Failed to fetch SSL/TLS service profiles. Check the connection settings."+ )+ }+ : undefined);++ return (+ <>+ <PkiSyncConnectionField+ onChange={() => {+ setValue("destinationConfig.template", "");+ clearProfile();+ }}+ />+ {deviceError && <FieldError className="-mt-2 mb-4" errors={[deviceError]} />}+ {isPanorama && (+ <Controller+ name="destinationConfig.template"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel>+ Template+ <Tooltip>+ <TooltipTrigger asChild>+ <Info />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ Panorama delivers certificates to firewalls through templates. The sync stores+ certificates in this template.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <FilterableSelect+ options={templates.map((name) => ({ name }))}+ value={value ? { name: value } : null}+ onChange={(option) => {+ onChange((option as { name: string } | null)?.name ?? "");+ clearErrors("destinationConfig.template");+ clearProfile();+ }}+ getOptionLabel={(option) => (option as { name: string }).name}+ getOptionValue={(option) => (option as { name: string }).name}+ placeholder="Select a template"+ isError={Boolean(error)}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ )}+ {withSslTlsServiceProfile && (+ <Field className="mb-4">+ <FieldLabel>+ SSL/TLS Service Profile+ <Tooltip>+ <TooltipTrigger asChild>+ <Info />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ The sync imports the certificate and sets it as this profile's certificate. A+ profile uses one certificate, and this sync holds one.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <FilterableSelect+ isDisabled={!isProfileSelectReady}+ isLoading={isLoadingProfiles}+ options={profiles}+ value={profileName ? { name: profileName, vsys: profileVsys ?? null } : null}+ onChange={(option) => {+ const profile = option as TPaloAltoNetworksSslTlsServiceProfile | null;+ setValue("destinationConfig.sslTlsServiceProfileVsys", profile?.vsys ?? "", {+ shouldDirty: true+ });+ setValue("destinationConfig.sslTlsServiceProfileName", profile?.name ?? "", {+ shouldDirty: true,+ shouldValidate: true+ });+ }}+ getOptionLabel={(option) =>+ getPaloAltoNetworksProfileLabel(option as TPaloAltoNetworksSslTlsServiceProfile)+ }+ getOptionValue={(option) =>+ getProfileValue(option as TPaloAltoNetworksSslTlsServiceProfile)+ }+ placeholder={profilePlaceholder}+ isError={Boolean(profileError)}+ />+ <FieldError errors={[profileError]} />+ </Field>+ )}+ {isPanorama && (+ <Controller+ name="destinationConfig.pushToDevices"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <Field orientation="horizontal">+ <FieldContent>+ <Label htmlFor="palo-alto-networks-push-to-devices">Push to Devices</Label>+ <FieldDescription>+ Pushes every template stack that contains this template to its firewalls when a+ sync changes the template.+ </FieldDescription>+ </FieldContent>+ <Toggle+ id="palo-alto-networks-push-to-devices"+ variant="project"+ checked={value ?? true}+ onCheckedChange={onChange}+ />+ </Field>+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ )}+ </>+ );+};diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncCertificatesFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncCertificatesFields.tsxindex 407d055423..778570196b 100644--- a/frontend/src/components/pki-syncs/forms/PkiSyncCertificatesFields.tsx+++ b/frontend/src/components/pki-syncs/forms/PkiSyncCertificatesFields.tsx@@ -141,7 +141,9 @@ export const PkiSyncCertificatesFields = ({ applicationId, pkiSyncId }: Props) =setOrderIds(certificateOrderIds);}}title={- certificateCap === 1 ? "Select a Certificate to Sync" : "Select Certificate Orders to Sync"+ certificateCap === 1+ ? "Select a Certificate Order to Sync"+ : "Select Certificate Orders to Sync"}subtitle="Selecting a certificate selects its order, so the sync follows every renewal of it."saveButtonText="Update Selection"@@ -170,10 +172,9 @@ export const PkiSyncCertificatesFields = ({ applicationId, pkiSyncId }: Props) =return (<div className="flex flex-col">- <p className="text-sm font-medium text-foreground">Certificate</p>+ <p className="text-sm font-medium text-foreground">Certificate Order</p><p className="mt-0.5 text-xs text-muted">- This destination holds one certificate. The order you pick stays synced through every- renewal of it.+ This destination holds one certificate order, which stays synced through every renewal.</p><div className="mt-3 flex items-center gap-3">{selectedOrderId ? (@@ -201,7 +202,7 @@ export const PkiSyncCertificatesFields = ({ applicationId, pkiSyncId }: Props) =size="xs"variant="ghost"className="hover:text-danger"- aria-label="Remove certificate"+ aria-label="Remove certificate order"onClick={() => setValue("filters", null, { shouldDirty: true })}><TrashIcon className="size-4" />@@ -209,7 +210,7 @@ export const PkiSyncCertificatesFields = ({ applicationId, pkiSyncId }: Props) =</>) : (<>- <p className="flex-1 text-sm text-muted">No certificate selected.</p>+ <p className="flex-1 text-sm text-muted">No certificate order selected.</p><Buttontype="button"size="sm"@@ -217,7 +218,7 @@ export const PkiSyncCertificatesFields = ({ applicationId, pkiSyncId }: Props) =className="h-9"onClick={() => setIsPickerOpen(true)}>- Select Certificate+ Select Certificate Order</Button></>)}diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsxindex 13bfab21bd..5ef33ac422 100644--- a/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsx+++ b/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsx@@ -15,6 +15,7 @@ import { KempLoadMasterPkiSyncFields } from "./KempLoadMasterPkiSyncFields";import { LinuxServerPkiSyncFields } from "./LinuxServerPkiSyncFields";import { NetScalerPkiSyncFields } from "./NetScalerPkiSyncFields";import { NutanixPrismCentralPkiSyncFields } from "./NutanixPrismCentralPkiSyncFields";+import { PaloAltoNetworksPkiSyncFields } from "./PaloAltoNetworksPkiSyncFields";import { WindowsServerPkiSyncFields } from "./WindowsServerPkiSyncFields";type Props = {@@ -43,6 +44,10 @@ export const PkiSyncDestinationFields = ({ isUpdate }: Props) => {return <GcpCertificateManagerPkiSyncFields isUpdate={isUpdate} />;case PkiSync.NetScaler:return <NetScalerPkiSyncFields />;+ case PkiSync.PaloAltoNetworks:+ return <PaloAltoNetworksPkiSyncFields />;+ case PkiSync.PaloAltoNetworksSslTlsProfile:+ return <PaloAltoNetworksPkiSyncFields withSslTlsServiceProfile />;case PkiSync.F5BigIp:return <F5BigIpPkiSyncFields />;case PkiSync.KempLoadMaster:diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PaloAltoNetworksSyncOptions.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PaloAltoNetworksSyncOptions.tsxnew file mode 100644index 0000000000..cdc0c5c2b4--- /dev/null+++ b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PaloAltoNetworksSyncOptions.tsx@@ -0,0 +1,8 @@+import { PreserveItemOnRenewalField } from "./PreserveItemOnRenewalField";++export const PaloAltoNetworksSyncOptions = () => (+ <PreserveItemOnRenewalField+ label="Preserve certificate on renewal"+ description="Applies to renewals only. When on, the renewed certificate replaces the existing certificate object under the same name, so anything that references it uses the renewed certificate. When off, the sync creates a new certificate object and moves the SSL/TLS service profile to it if the sync has one. The old object is deleted when removing certificates is allowed."+ />+);diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsxindex a3827611fc..f5a5c9dda6 100644--- a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx+++ b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx@@ -1,6 +1,7 @@import { Controller, useFormContext } from "react-hook-form";import { Field, FieldDescription, FieldError, FieldLabel, Input } from "@app/components/v3";+import { INCLUDE_ROOT_CA_UNSUPPORTED_DESTINATIONS } from "@app/helpers/pkiSyncs";import { PkiSync, usePkiSyncOption } from "@app/hooks/api/pkiSyncs";import { TPkiSyncForm } from "../schemas/pki-sync-schema";@@ -15,6 +16,7 @@ import { KempLoadMasterSyncOptions } from "./KempLoadMasterSyncOptions";import { LinuxServerSyncOptions } from "./LinuxServerSyncOptions";import { NameSchemaHoverCard } from "./NameSchemaHoverCard";import { NetScalerSyncOptions } from "./NetScalerSyncOptions";+import { PaloAltoNetworksSyncOptions } from "./PaloAltoNetworksSyncOptions";import { SyncSwitchField } from "./SyncSwitchField";import { WindowsServerSyncOptions } from "./WindowsServerSyncOptions";@@ -39,6 +41,9 @@ const renderDestinationOptions = (currentDestination: PkiSync, isUpdate?: booleareturn <GcpCertificateManagerSyncOptions />;case PkiSync.NetScaler:return <NetScalerSyncOptions />;+ case PkiSync.PaloAltoNetworks:+ case PkiSync.PaloAltoNetworksSslTlsProfile:+ return <PaloAltoNetworksSyncOptions />;case PkiSync.F5BigIp:return <F5BigIpSyncOptions />;case PkiSync.KempLoadMaster:@@ -77,15 +82,14 @@ export const PkiSyncOptionsFields = ({ destination, isUpdate }: Props) => {/>)}- {currentDestination !== PkiSync.CloudflareCustomCertificate &&- currentDestination !== PkiSync.NutanixPrismCentral && (- <SyncSwitchField- name="syncOptions.includeRootCa"- id="include-root-ca"- label="Include root CA in certificate chain"- description="When enabled, the full certificate chain including the root CA is synced. When disabled, the root CA is excluded to reduce the chain size; most applications validate correctly with intermediate certificates only."- />- )}+ {!INCLUDE_ROOT_CA_UNSUPPORTED_DESTINATIONS.includes(currentDestination) && (+ <SyncSwitchField+ name="syncOptions.includeRootCa"+ id="include-root-ca"+ label="Include root CA in certificate chain"+ description="When enabled, the full certificate chain including the root CA is synced. When disabled, the root CA is excluded to reduce the chain size; most applications validate correctly with intermediate certificates only."+ />+ )}{renderDestinationOptions(currentDestination, isUpdate)}diff --git a/frontend/src/components/pki-syncs/forms/schemas/palo-alto-networks-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/palo-alto-networks-pki-sync-destination-schema.tsnew file mode 100644index 0000000000..b466176af3--- /dev/null+++ b/frontend/src/components/pki-syncs/forms/schemas/palo-alto-networks-pki-sync-destination-schema.ts@@ -0,0 +1,138 @@+import { z } from "zod";++import { PkiSync } from "@app/hooks/api/pkiSyncs";++import { BasePkiSyncSchema } from "./base-pki-sync-schema";++const PAN_OS_OBJECT_NAME_REGEX = /^[A-Za-z0-9 ._-]+$/;++const panOsObjectNameSchema = (field: string) =>+ z+ .string({ required_error: `${field} is required` })+ .trim()+ .min(1, `${field} is required`)+ .max(63, `${field} cannot exceed 63 characters`)+ .regex(+ PAN_OS_OBJECT_NAME_REGEX,+ `${field} can only contain letters, numbers, spaces, periods, hyphens, and underscores`+ );++const PaloAltoNetworksSyncOptionsSchema = z.object({+ canRemoveCertificates: z.boolean().default(true),+ preserveItemOnRenewal: z.boolean().default(true),+ certificateNameSchema: z+ .string()+ .trim()+ .min(1, "Certificate name schema is required")+ .refine(+ (val) => {+ const allowedOptionalPlaceholders = [+ "{{profileId}}",+ "{{applicationId}}",+ "{{applicationName}}",+ "{{commonName}}"+ ];++ const allowedPlaceholdersRegexPart = [+ "{{certificateId}}",+ "{{shortCertificateId}}",+ ...allowedOptionalPlaceholders+ ]+ .map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))+ .join("|");++ const allowedContentRegex = new RegExp(+ `^([a-zA-Z0-9_\\-]|${allowedPlaceholdersRegexPart})*$`+ );+ const contentIsValid = allowedContentRegex.test(val);++ const compiledLength = val+ .replace(/\{\{shortCertificateId\}\}/g, "0".repeat(22))+ .replace(/\{\{certificateId\}\}/g, "0".repeat(32))+ .replace(/\{\{profileId\}\}/g, "0".repeat(32))+ .replace(/\{\{applicationId\}\}/g, "0".repeat(32))+ .replace(/\{\{applicationName\}\}/g, "application-name")+ .replace(/\{\{commonName\}\}/g, "common-name").length;+ const lengthIsValid = compiledLength <= 31;++ const certificateIdIsPresent =+ val.includes("{{certificateId}}") || val.includes("{{shortCertificateId}}");+ return contentIsValid && certificateIdIsPresent && lengthIsValid;+ },+ {+ message:+ "Certificate name schema must include {{shortCertificateId}} and be at most 31 characters once placeholders are filled in ({{shortCertificateId}} counts as 22). It can also use {{applicationName}} and {{commonName}}. Outside placeholders, use only letters, numbers, hyphens (-), and underscores (_)."+ }+ )+});++const clearablePanOsObjectNameSchema = (field: string) =>+ z+ .union([z.literal(""), panOsObjectNameSchema(field)])+ .optional()+ .transform((value) => value || undefined);++const PaloAltoNetworksDestinationConfigSchema = z.object({+ template: clearablePanOsObjectNameSchema("Template"),+ pushToDevices: z.boolean().default(true)+});++const PaloAltoNetworksSslTlsProfileDestinationConfigSchema =+ PaloAltoNetworksDestinationConfigSchema.extend({+ sslTlsServiceProfileName: panOsObjectNameSchema("SSL/TLS service profile"),+ sslTlsServiceProfileVsys: clearablePanOsObjectNameSchema("Virtual system")+ });++const buildPaloAltoNetworksDestinationSchemas = <+ TDestination extends PkiSync,+ TConfig extends z.ZodTypeAny+>(+ destination: TDestination,+ destinationConfig: TConfig+) => {+ const createSchema = BasePkiSyncSchema(PaloAltoNetworksSyncOptionsSchema).merge(+ z.object({+ destination: z.literal(destination),+ destinationConfig+ })+ );++ const updateSchema = createSchema.partial().merge(+ z.object({+ name: z+ .string()+ .trim()+ .min(1, "Name is required")+ .max(255, "Name must be less than 255 characters"),+ destination: z.literal(destination),+ connection: z.object({+ id: z.string().uuid("Invalid connection ID format"),+ name: z+ .string()+ .min(1, "Connection name is required")+ .max(255, "Connection name must be less than 255 characters")+ })+ })+ );++ return { createSchema, updateSchema };+};++export const PaloAltoNetworksDestinationSchemas = buildPaloAltoNetworksDestinationSchemas(+ PkiSync.PaloAltoNetworks,+ PaloAltoNetworksDestinationConfigSchema+);++export const PaloAltoNetworksSslTlsProfileDestinationSchemas =+ buildPaloAltoNetworksDestinationSchemas(+ PkiSync.PaloAltoNetworksSslTlsProfile,+ PaloAltoNetworksSslTlsProfileDestinationConfigSchema+ );++export const PALO_ALTO_NETWORKS_TEMPLATE_REQUIRED_MESSAGE =+ "Select the Panorama template to store the certificates in";++export const isPaloAltoNetworksTemplateMissing = (+ isPanorama: boolean | undefined,+ destinationConfig: unknown+) => Boolean(isPanorama) && !(destinationConfig as { template?: string } | undefined)?.template;diff --git a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.tsindex 52c1fe9345..f259a60be7 100644--- a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts+++ b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts@@ -57,6 +57,10 @@ import {NutanixPrismCentralPkiSyncDestinationSchema,UpdateNutanixPrismCentralPkiSyncDestinationSchema} from "./nutanix-prism-central-pki-sync-destination-schema";+import {+ PaloAltoNetworksDestinationSchemas,+ PaloAltoNetworksSslTlsProfileDestinationSchemas+} from "./palo-alto-networks-pki-sync-destination-schema";import {UpdateWindowsServerPkiSyncDestinationSchema,WindowsServerPkiSyncDestinationSchema@@ -71,6 +75,8 @@ const PkiSyncUnionSchema = z.discriminatedUnion("destination", [CloudflareCustomCertificatePkiSyncDestinationSchema,GcpCertificateManagerPkiSyncDestinationSchema,NetScalerPkiSyncDestinationSchema,+ PaloAltoNetworksDestinationSchemas.createSchema,+ PaloAltoNetworksSslTlsProfileDestinationSchemas.createSchema,F5BigIpPkiSyncDestinationSchema,KempLoadMasterPkiSyncDestinationSchema,LinuxServerPkiSyncDestinationSchema,@@ -87,6 +93,8 @@ const UpdatePkiSyncUnionSchema = z.discriminatedUnion("destination", [UpdateCloudflareCustomCertificatePkiSyncDestinationSchema,UpdateGcpCertificateManagerPkiSyncDestinationSchema,UpdateNetScalerPkiSyncDestinationSchema,+ PaloAltoNetworksDestinationSchemas.updateSchema,+ PaloAltoNetworksSslTlsProfileDestinationSchemas.updateSchema,UpdateF5BigIpPkiSyncDestinationSchema,UpdateKempLoadMasterPkiSyncDestinationSchema,UpdateLinuxServerPkiSyncDestinationSchema,diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.tsindex be90197232..a8d28e150d 100644--- a/frontend/src/helpers/appConnections.ts+++ b/frontend/src/helpers/appConnections.ts@@ -86,6 +86,7 @@ import { OnaConnectionMethod } from "@app/hooks/api/appConnections/types/ona-conimport { OpenAIConnectionMethod } from "@app/hooks/api/appConnections/types/open-ai-connection";import { OpenRouterConnectionMethod } from "@app/hooks/api/appConnections/types/open-router-connection";import { OVHConnectionMethod } from "@app/hooks/api/appConnections/types/ovh-connection";+import { PaloAltoNetworksConnectionMethod } from "@app/hooks/api/appConnections/types/palo-alto-networks-connection";import { PowerDnsConnectionMethod } from "@app/hooks/api/appConnections/types/powerdns-connection";import { RailwayConnectionMethod } from "@app/hooks/api/appConnections/types/railway-connection";import { RenderConnectionMethod } from "@app/hooks/api/appConnections/types/render-connection";@@ -519,6 +520,12 @@ export const APP_CONNECTION_MAP: Record<category: "NETWORKING",description: "Manage a Citrix NetScaler appliance."},+ [AppConnection.PaloAltoNetworks]: {+ name: "Palo Alto Networks",+ image: "Palo Alto Networks.png",+ category: "NETWORKING",+ description: "Connect to a Palo Alto Networks firewall or Panorama."+ },[AppConnection.KempLoadMaster]: {name: "Kemp LoadMaster",image: "Kemp LoadMaster.png",@@ -798,6 +805,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])case ExternalInfisicalConnectionMethod.MachineIdentityUniversalAuth:return { name: "Machine Identity - Universal Auth", icon: KeyRoundIcon };case NetScalerConnectionMethod.BasicAuth:+ case PaloAltoNetworksConnectionMethod.BasicAuth:case KempLoadMasterConnectionMethod.BasicAuth:case NutanixPrismCentralConnectionMethod.BasicAuth:case F5BigIpConnectionMethod.BasicAuth:diff --git a/frontend/src/helpers/pkiSyncs.ts b/frontend/src/helpers/pkiSyncs.tsindex df162816b9..46ad6b5c5e 100644--- a/frontend/src/helpers/pkiSyncs.ts+++ b/frontend/src/helpers/pkiSyncs.ts@@ -64,6 +64,18 @@ export const PKI_SYNC_MAP: Record<category: "Networking",description: "Sync certificates to Citrix NetScaler / ADC."},+ [PkiSync.PaloAltoNetworks]: {+ name: "Palo Alto Networks",+ image: "Palo Alto Networks.png",+ category: "Networking",+ description: "Push certificates to a Palo Alto Networks firewall or Panorama template."+ },+ [PkiSync.PaloAltoNetworksSslTlsProfile]: {+ name: "Palo Alto Networks SSL/TLS Profile",+ image: "Palo Alto Networks.png",+ category: "Networking",+ description: "Set the certificate of a Palo Alto Networks SSL/TLS service profile."+ },[PkiSync.F5BigIp]: {name: "F5 BIG-IP",image: "F5 BIG-IP.png",@@ -132,6 +144,8 @@ export const PKI_SYNC_CONNECTION_MAP: Record<PkiSync, AppConnection> = {[PkiSync.GcpCertificateManager]: AppConnection.GCP,[PkiSync.CloudflareCustomCertificate]: AppConnection.Cloudflare,[PkiSync.NetScaler]: AppConnection.NetScaler,+ [PkiSync.PaloAltoNetworks]: AppConnection.PaloAltoNetworks,+ [PkiSync.PaloAltoNetworksSslTlsProfile]: AppConnection.PaloAltoNetworks,[PkiSync.F5BigIp]: AppConnection.F5BigIp,[PkiSync.KempLoadMaster]: AppConnection.KempLoadMaster,[PkiSync.LinuxServer]: AppConnection.SSH,@@ -175,9 +189,29 @@ export const PRESERVE_ITEM_ON_RENEWAL_DESTINATIONS: PkiSync[] = [PkiSync.F5BigIp,PkiSync.GcpCertificateManager,PkiSync.KempLoadMaster,- PkiSync.NetScaler+ PkiSync.NetScaler,+ PkiSync.PaloAltoNetworks,+ PkiSync.PaloAltoNetworksSslTlsProfile];+export const INCLUDE_ROOT_CA_UNSUPPORTED_DESTINATIONS: PkiSync[] = [+ PkiSync.CloudflareCustomCertificate,+ PkiSync.NutanixPrismCentral,+ PkiSync.PaloAltoNetworks,+ PkiSync.PaloAltoNetworksSslTlsProfile+];++export const isPaloAltoNetworksPkiSync = (destination?: PkiSync) =>+ destination === PkiSync.PaloAltoNetworks || destination === PkiSync.PaloAltoNetworksSslTlsProfile;++export const getPaloAltoNetworksProfileLabel = ({+ name,+ vsys+}: {+ name: string;+ vsys?: string | null;+}) => (vsys ? `${name} (${vsys})` : name);+export const VALUE_SYNC_OPTION_FIELDS = [{ key: "certificateNameSchema", label: "Certificate Name Schema" },{ key: "caCertificateNameSchema", label: "CA Certificate Name Schema" },diff --git a/frontend/src/hooks/api/appConnections/enums.ts b/frontend/src/hooks/api/appConnections/enums.tsindex a96510fac9..db4453ba08 100644--- a/frontend/src/hooks/api/appConnections/enums.ts+++ b/frontend/src/hooks/api/appConnections/enums.ts@@ -62,6 +62,7 @@ export enum AppConnection {ExternalInfisical = "external-infisical",Doppler = "doppler",NetScaler = "netscaler",+ PaloAltoNetworks = "palo-alto-networks",KempLoadMaster = "kemp-loadmaster",Anthropic = "anthropic",OVH = "ovh",diff --git a/frontend/src/hooks/api/appConnections/palo-alto-networks/index.ts b/frontend/src/hooks/api/appConnections/palo-alto-networks/index.tsnew file mode 100644index 0000000000..b69c251208--- /dev/null+++ b/frontend/src/hooks/api/appConnections/palo-alto-networks/index.ts@@ -0,0 +1 @@+export * from "./queries";diff --git a/frontend/src/hooks/api/appConnections/palo-alto-networks/queries.tsx b/frontend/src/hooks/api/appConnections/palo-alto-networks/queries.tsxnew file mode 100644index 0000000000..59374a6b86--- /dev/null+++ b/frontend/src/hooks/api/appConnections/palo-alto-networks/queries.tsx@@ -0,0 +1,89 @@+import { useQuery, UseQueryOptions } from "@tanstack/react-query";++import { apiRequest } from "@app/config/request";++import { appConnectionKeys } from "../queries";++export type TPaloAltoNetworksTemplates = {+ isPanorama: boolean;+ templates: string[];+};++export type TPaloAltoNetworksSslTlsServiceProfile = {+ name: string;+ vsys: string | null;+};++const DEVICE_LOOKUP_STALE_TIME_MS = 5 * 60 * 1000;++const paloAltoNetworksConnectionKeys = {+ all: [...appConnectionKeys.all, "palo-alto-networks"] as const,+ listTemplates: (connectionId: string) =>+ [...paloAltoNetworksConnectionKeys.all, "templates", connectionId] as const,+ listSslTlsServiceProfiles: (connectionId: string, template?: string) =>+ [+ ...paloAltoNetworksConnectionKeys.all,+ "ssl-tls-service-profiles",+ connectionId,+ template+ ] as const+};++export const usePaloAltoNetworksConnectionListTemplates = (+ connectionId: string,+ options?: Omit<+ UseQueryOptions<+ TPaloAltoNetworksTemplates,+ unknown,+ TPaloAltoNetworksTemplates,+ ReturnType<typeof paloAltoNetworksConnectionKeys.listTemplates>+ >,+ "queryKey" | "queryFn"+ >+) => {+ return useQuery({+ queryKey: paloAltoNetworksConnectionKeys.listTemplates(connectionId),+ queryFn: async () => {+ const { data } = await apiRequest.get<TPaloAltoNetworksTemplates>(+ `/api/v1/app-connections/palo-alto-networks/${connectionId}/templates`+ );++ return data;+ },+ staleTime: DEVICE_LOOKUP_STALE_TIME_MS,+ refetchOnWindowFocus: false,+ ...options,+ enabled: Boolean(connectionId) && (options?.enabled ?? true)+ });+};++export const usePaloAltoNetworksConnectionListSslTlsServiceProfiles = (+ connectionId: string,+ template?: string,+ options?: Omit<+ UseQueryOptions<+ TPaloAltoNetworksSslTlsServiceProfile[],+ unknown,+ TPaloAltoNetworksSslTlsServiceProfile[],+ ReturnType<typeof paloAltoNetworksConnectionKeys.listSslTlsServiceProfiles>+ >,+ "queryKey" | "queryFn"+ >+) => {+ return useQuery({+ queryKey: paloAltoNetworksConnectionKeys.listSslTlsServiceProfiles(connectionId, template),+ queryFn: async () => {+ const { data } = await apiRequest.get<{+ sslTlsServiceProfiles: TPaloAltoNetworksSslTlsServiceProfile[];+ }>(`/api/v1/app-connections/palo-alto-networks/${connectionId}/ssl-tls-service-profiles`, {+ params: template ? { template } : undefined+ });++ return data.sslTlsServiceProfiles;+ },+ staleTime: DEVICE_LOOKUP_STALE_TIME_MS,+ refetchOnWindowFocus: false,+ ...options,+ enabled: Boolean(connectionId) && (options?.enabled ?? true)+ });+};diff --git a/frontend/src/hooks/api/appConnections/types/app-options.ts b/frontend/src/hooks/api/appConnections/types/app-options.tsindex b7c6b5cddc..ce71fd0d51 100644--- a/frontend/src/hooks/api/appConnections/types/app-options.ts+++ b/frontend/src/hooks/api/appConnections/types/app-options.ts@@ -281,6 +281,10 @@ export type TNetScalerConnectionOption = TAppConnectionOptionBase & {app: AppConnection.NetScaler;};+export type TPaloAltoNetworksConnectionOption = TAppConnectionOptionBase & {+ app: AppConnection.PaloAltoNetworks;+};+export type TKempLoadMasterConnectionOption = TAppConnectionOptionBase & {app: AppConnection.KempLoadMaster;};@@ -429,6 +433,7 @@ export type TAppConnectionOption =| TExternalInfisicalConnectionOption| TDopplerConnectionOption| TNetScalerConnectionOption+ | TPaloAltoNetworksConnectionOption| TKempLoadMasterConnectionOption| TAnthropicConnectionOption| TOvhConnectionOption@@ -518,6 +523,7 @@ export type TAppConnectionOptionMap = {[AppConnection.ExternalInfisical]: TExternalInfisicalConnectionOption;[AppConnection.Doppler]: TDopplerConnectionOption;[AppConnection.NetScaler]: TNetScalerConnectionOption;+ [AppConnection.PaloAltoNetworks]: TPaloAltoNetworksConnectionOption;[AppConnection.KempLoadMaster]: TKempLoadMasterConnectionOption;[AppConnection.Anthropic]: TAnthropicConnectionOption;[AppConnection.OVH]: TOvhConnectionOption;diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.tsindex 6a0ecd242a..f5fc7fd873 100644--- a/frontend/src/hooks/api/appConnections/types/index.ts+++ b/frontend/src/hooks/api/appConnections/types/index.ts@@ -62,6 +62,7 @@ import { TOpenAIConnection } from "./open-ai-connection";import { TOpenRouterConnection } from "./open-router-connection";import { TOracleDBConnection } from "./oracledb-connection";import { TOvhConnection } from "./ovh-connection";+import { TPaloAltoNetworksConnection } from "./palo-alto-networks-connection";import { TPostgresConnection } from "./postgres-connection";import { TPowerDnsConnection } from "./powerdns-connection";import { TQoveryConnection } from "./qovery-connection";@@ -147,6 +148,7 @@ export * from "./open-ai-connection";export * from "./open-router-connection";export * from "./oracledb-connection";export * from "./ovh-connection";+export * from "./palo-alto-networks-connection";export * from "./postgres-connection";export * from "./powerdns-connection";export * from "./qovery-connection";@@ -237,6 +239,7 @@ export type TAppConnection =| TVenafiTppConnection| TExternalInfisicalConnection| TNetScalerConnection+ | TPaloAltoNetworksConnection| TKempLoadMasterConnection| TDopplerConnection| TOvhConnectiondiff --git a/frontend/src/hooks/api/appConnections/types/palo-alto-networks-connection.ts b/frontend/src/hooks/api/appConnections/types/palo-alto-networks-connection.tsnew file mode 100644index 0000000000..86dcd54a25--- /dev/null+++ b/frontend/src/hooks/api/appConnections/types/palo-alto-networks-connection.ts@@ -0,0 +1,20 @@+import { AppConnection } from "@app/hooks/api/appConnections/enums";+import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";++export enum PaloAltoNetworksConnectionMethod {+ BasicAuth = "basic-auth"+}++export type TPaloAltoNetworksConnection = TRootAppConnection & {+ app: AppConnection.PaloAltoNetworks;+} & {+ method: PaloAltoNetworksConnectionMethod.BasicAuth;+ credentials: {+ hostname: string;+ port?: number;+ username: string;+ password: string;+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;+ };+};diff --git a/frontend/src/hooks/api/pkiSyncs/enums.ts b/frontend/src/hooks/api/pkiSyncs/enums.tsindex cb43097beb..af6ccb6c30 100644--- a/frontend/src/hooks/api/pkiSyncs/enums.ts+++ b/frontend/src/hooks/api/pkiSyncs/enums.ts@@ -7,6 +7,8 @@ export enum PkiSync {GcpCertificateManager = "gcp-certificate-manager",CloudflareCustomCertificate = "cloudflare-custom-certificate",NetScaler = "netscaler",+ PaloAltoNetworks = "palo-alto-networks",+ PaloAltoNetworksSslTlsProfile = "palo-alto-networks-ssl-tls-profile",F5BigIp = "f5-big-ip",KempLoadMaster = "kemp-loadmaster",LinuxServer = "linux-server",diff --git a/frontend/src/hooks/api/pkiSyncs/types/index.ts b/frontend/src/hooks/api/pkiSyncs/types/index.tsindex d7c6f88b85..cf1d52b918 100644--- a/frontend/src/hooks/api/pkiSyncs/types/index.ts+++ b/frontend/src/hooks/api/pkiSyncs/types/index.ts@@ -17,6 +17,10 @@ import { TKempLoadMasterPkiSync } from "./kemp-loadmaster-sync";import { TLinuxServerPkiSync } from "./linux-server-sync";import { TNetScalerPkiSync } from "./netscaler-sync";import { TNutanixPrismCentralPkiSync } from "./nutanix-prism-central-sync";+import {+ TPaloAltoNetworksPkiSync,+ TPaloAltoNetworksSslTlsProfilePkiSync+} from "./palo-alto-networks-sync";import { TWindowsServerPkiSync } from "./windows-server-sync";export type TPkiSyncOption = {@@ -45,6 +49,8 @@ export type TPkiSync =| TCloudflareCustomCertificatePkiSync| TGcpCertificateManagerPkiSync| TNetScalerPkiSync+ | TPaloAltoNetworksPkiSync+ | TPaloAltoNetworksSslTlsProfilePkiSync| TF5BigIpPkiSync| TKempLoadMasterPkiSync| TLinuxServerPkiSync@@ -105,6 +111,10 @@ export type TCreatePkiSyncDTO = TCreatePkiSyncDTOBase & {}>;zoneId?: string;vserverName?: string;+ template?: string;+ sslTlsServiceProfileName?: string;+ sslTlsServiceProfileVsys?: string;+ pushToDevices?: boolean;virtualServiceId?: string;partition?: string;profileType?: string;@@ -166,4 +176,5 @@ export * from "./kemp-loadmaster-sync";export * from "./linux-server-sync";export * from "./netscaler-sync";export * from "./nutanix-prism-central-sync";+export * from "./palo-alto-networks-sync";export * from "./windows-server-sync";diff --git a/frontend/src/hooks/api/pkiSyncs/types/palo-alto-networks-sync.ts b/frontend/src/hooks/api/pkiSyncs/types/palo-alto-networks-sync.tsnew file mode 100644index 0000000000..0064c90bf4--- /dev/null+++ b/frontend/src/hooks/api/pkiSyncs/types/palo-alto-networks-sync.ts@@ -0,0 +1,28 @@+import { AppConnection } from "@app/hooks/api/appConnections/enums";++import { PkiSync } from "../enums";+import { TRootPkiSync } from "./common";++type TPaloAltoNetworksBasePkiSync = TRootPkiSync & {+ connection: {+ app: AppConnection.PaloAltoNetworks;+ name: string;+ id: string;+ };+};++export type TPaloAltoNetworksPkiSync = TPaloAltoNetworksBasePkiSync & {+ destination: PkiSync.PaloAltoNetworks;+ destinationConfig: {+ template?: string;+ pushToDevices: boolean;+ };+};++export type TPaloAltoNetworksSslTlsProfilePkiSync = TPaloAltoNetworksBasePkiSync & {+ destination: PkiSync.PaloAltoNetworksSslTlsProfile;+ destinationConfig: TPaloAltoNetworksPkiSync["destinationConfig"] & {+ sslTlsServiceProfileName: string;+ sslTlsServiceProfileVsys?: string;+ };+};diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection.tsxindex 8e03be0bbd..29cd46cbb4 100644--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection.tsx+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection.tsx@@ -16,6 +16,7 @@ import {LinuxServerPkiSyncDestinationSection,NetScalerPkiSyncDestinationSection,NutanixPrismCentralPkiSyncDestinationSection,+ PaloAltoNetworksPkiSyncDestinationSection,WindowsServerPkiSyncDestinationSection} from "./PkiSyncDestinationSection/index";@@ -51,6 +52,10 @@ export const PkiSyncDestinationSection = ({ pkiSync }: Props) => {case PkiSync.NetScaler:DestinationComponents = <NetScalerPkiSyncDestinationSection pkiSync={pkiSync} />;break;+ case PkiSync.PaloAltoNetworks:+ case PkiSync.PaloAltoNetworksSslTlsProfile:+ DestinationComponents = <PaloAltoNetworksPkiSyncDestinationSection pkiSync={pkiSync} />;+ break;case PkiSync.F5BigIp:DestinationComponents = <F5BigIpPkiSyncDestinationSection pkiSync={pkiSync} />;break;diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/PaloAltoNetworksPkiSyncDestinationSection.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/PaloAltoNetworksPkiSyncDestinationSection.tsxnew file mode 100644index 0000000000..074c2b3374--- /dev/null+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/PaloAltoNetworksPkiSyncDestinationSection.tsx@@ -0,0 +1,45 @@+import { Detail, DetailLabel, DetailValue } from "@app/components/v3";+import { getPaloAltoNetworksProfileLabel } from "@app/helpers/pkiSyncs";+import { PkiSync } from "@app/hooks/api/pkiSyncs";+import {+ TPaloAltoNetworksPkiSync,+ TPaloAltoNetworksSslTlsProfilePkiSync+} from "@app/hooks/api/pkiSyncs/types/palo-alto-networks-sync";++type Props = {+ pkiSync: TPaloAltoNetworksPkiSync | TPaloAltoNetworksSslTlsProfilePkiSync;+};++export const PaloAltoNetworksPkiSyncDestinationSection = ({ pkiSync }: Props) => {+ const { template, pushToDevices } = pkiSync.destinationConfig;+ const { sslTlsServiceProfileName, sslTlsServiceProfileVsys } =+ pkiSync.destination === PkiSync.PaloAltoNetworksSslTlsProfile ? pkiSync.destinationConfig : {};++ return (+ <>+ {template && (+ <>+ <Detail>+ <DetailLabel>Template</DetailLabel>+ <DetailValue>{template}</DetailValue>+ </Detail>+ <Detail>+ <DetailLabel>Push to Devices</DetailLabel>+ <DetailValue>{pushToDevices ? "Enabled" : "Disabled"}</DetailValue>+ </Detail>+ </>+ )}+ {sslTlsServiceProfileName && (+ <Detail>+ <DetailLabel>SSL/TLS Service Profile</DetailLabel>+ <DetailValue>+ {getPaloAltoNetworksProfileLabel({+ name: sslTlsServiceProfileName,+ vsys: sslTlsServiceProfileVsys+ })}+ </DetailValue>+ </Detail>+ )}+ </>+ );+};diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/index.ts b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/index.tsindex f5e9966832..992a44ead8 100644--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/index.ts+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/index.ts@@ -9,4 +9,5 @@ export { KempLoadMasterPkiSyncDestinationSection } from "./KempLoadMasterPkiSyncexport { LinuxServerPkiSyncDestinationSection } from "./LinuxServerPkiSyncDestinationSection";export { NetScalerPkiSyncDestinationSection } from "./NetScalerPkiSyncDestinationSection";export { NutanixPrismCentralPkiSyncDestinationSection } from "./NutanixPrismCentralPkiSyncDestinationSection";+export { PaloAltoNetworksPkiSyncDestinationSection } from "./PaloAltoNetworksPkiSyncDestinationSection";export { WindowsServerPkiSyncDestinationSection } from "./WindowsServerPkiSyncDestinationSection";diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncOptionsSection/PkiSyncOptionsSection.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncOptionsSection/PkiSyncOptionsSection.tsxindex dca4302f4d..c1c4e61c31 100644--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncOptionsSection/PkiSyncOptionsSection.tsx+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncOptionsSection/PkiSyncOptionsSection.tsx@@ -31,7 +31,7 @@ export const PkiSyncOptionsSection = ({ pkiSync }: Props) => {return (<>- <Separator />+ <Separator className="mt-4" /><Accordion type="multiple" variant="ghost"><AccordionItem value="sync-options"><AccordionTrigger className="py-4">Sync Options</AccordionTrigger>diff --git a/frontend/src/pages/cert-manager/pki-docs-urls.ts b/frontend/src/pages/cert-manager/pki-docs-urls.tsindex f76db1f843..026bf2b13b 100644--- a/frontend/src/pages/cert-manager/pki-docs-urls.ts+++ b/frontend/src/pages/cert-manager/pki-docs-urls.ts@@ -62,6 +62,8 @@ export const PkiDocsUrls = {azureKeyVault: `${PKI_DOCS_BASE_URL}/applications/certificate-syncs/azure-key-vault`,cloudflare: `${PKI_DOCS_BASE_URL}/applications/certificate-syncs/cloudflare-custom-certificate`,netscaler: `${PKI_DOCS_BASE_URL}/applications/certificate-syncs/netscaler`,+ paloAltoNetworks: `${PKI_DOCS_BASE_URL}/applications/certificate-syncs/palo-alto-networks`,+ paloAltoNetworksSslTlsProfile: `${PKI_DOCS_BASE_URL}/applications/certificate-syncs/palo-alto-networks-ssl-tls-profile`,chef: `${PKI_DOCS_BASE_URL}/applications/certificate-syncs/chef`}},diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsxindex 77e7932cda..11fc819050 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx@@ -76,6 +76,7 @@ import { OpenAIConnectionForm } from "./OpenAIConnectionForm";import { OpenRouterConnectionForm } from "./OpenRouterConnectionForm";import { OracleDBConnectionForm } from "./OracleDBConnectionForm";import { OVHConnectionForm } from "./OVHConnectionForm";+import { PaloAltoNetworksConnectionForm } from "./PaloAltoNetworksConnectionForm";import { PostgresConnectionForm } from "./PostgresConnectionForm";import { PowerDnsConnectionForm } from "./PowerDnsConnectionForm";import { QoveryConnectionForm } from "./QoveryConnectionForm";@@ -346,6 +347,8 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {return <DopplerConnectionForm onSubmit={onSubmit} />;case AppConnection.NetScaler:return <NetScalerConnectionForm onSubmit={onSubmit} />;+ case AppConnection.PaloAltoNetworks:+ return <PaloAltoNetworksConnectionForm onSubmit={onSubmit} />;case AppConnection.KempLoadMaster:return <KempLoadMasterConnectionForm onSubmit={onSubmit} />;case AppConnection.OVH:@@ -629,6 +632,8 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {return <DopplerConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.NetScaler:return <NetScalerConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;+ case AppConnection.PaloAltoNetworks:+ return <PaloAltoNetworksConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.KempLoadMaster:return <KempLoadMasterConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.OVH:diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/PaloAltoNetworksConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/PaloAltoNetworksConnectionForm.tsxnew file mode 100644index 0000000000..97f12777a1--- /dev/null+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/PaloAltoNetworksConnectionForm.tsx@@ -0,0 +1,377 @@+import { useState } from "react";+import { Controller, FormProvider, useForm } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import { Info } from "lucide-react";+import { z } from "zod";++import { OrgPermissionCan } from "@app/components/permissions";+import {+ Field,+ FieldContent,+ FieldDescription,+ FieldError,+ FieldLabel,+ Input,+ Label,+ SecretInput,+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+ Tabs,+ TabsContent,+ TabsList,+ TabsTrigger,+ TextArea,+ Toggle,+ Tooltip,+ TooltipContent,+ TooltipTrigger+} from "@app/components/v3";+import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";+import { OrgPermissionSubjects } from "@app/context";+import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";+import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";+import { useScopeVariant } from "@app/hooks";+import {+ PaloAltoNetworksConnectionMethod,+ TPaloAltoNetworksConnection+} from "@app/hooks/api/appConnections";+import { AppConnection } from "@app/hooks/api/appConnections/enums";++import { AppConnectionFormFooter } from "./AppConnectionFormFooter";+import {+ genericAppConnectionFieldsSchema,+ GenericAppConnectionsFields+} from "./GenericAppConnectionFields";++type Props = {+ appConnection?: TPaloAltoNetworksConnection;+ onSubmit: (formData: FormData) => Promise<void>;+};++const rootSchema = genericAppConnectionFieldsSchema.extend({+ app: z.literal(AppConnection.PaloAltoNetworks)+});++const formSchema = z.discriminatedUnion("method", [+ rootSchema.extend({+ method: z.literal(PaloAltoNetworksConnectionMethod.BasicAuth),+ credentials: z.object({+ hostname: z+ .string()+ .trim()+ .min(1, "Hostname is required")+ .max(512, "Hostname cannot exceed 512 characters")+ .refine((val) => !val.includes("/") && !val.includes("@") && !val.includes("?"), {+ message: "Hostname must not contain /, @, or ? characters"+ }),+ port: z.coerce.number().int().min(1).max(65535).optional(),+ username: z+ .string()+ .trim()+ .min(1, "Username is required")+ .max(256, "Username cannot exceed 256 characters"),+ password: z+ .string()+ .min(1, "Password is required")+ .max(512, "Password cannot exceed 512 characters"),+ sslRejectUnauthorized: z.boolean(),+ sslCertificate: z+ .string()+ .trim()+ .transform((value) => value || undefined)+ .optional()+ })+ })+]);++type FormData = z.infer<typeof formSchema>;++export const PaloAltoNetworksConnectionForm = ({ appConnection, onSubmit }: Props) => {+ const isUpdate = Boolean(appConnection);+ const [selectedTab, setSelectedTab] = useState("configuration");++ const form = useForm<FormData>({+ resolver: zodResolver(formSchema),+ defaultValues: appConnection ?? {+ app: AppConnection.PaloAltoNetworks,+ method: PaloAltoNetworksConnectionMethod.BasicAuth,+ gatewayId: null,+ gatewayPoolId: null,+ credentials: {+ sslRejectUnauthorized: true,+ sslCertificate: undefined+ }+ }+ });++ const { handleSubmit, control, setValue, watch } = form;+ const scopeVariant = useScopeVariant();++ const gatewayId = watch("gatewayId");+ const gatewayPoolId = watch("gatewayPoolId");++ return (+ <FormProvider {...form}>+ <form onSubmit={handleSubmit(onSubmit)}>+ {!isUpdate && <GenericAppConnectionsFields />}+ <OrgPermissionCan+ I={OrgGatewayPermissionActions.AttachGateways}+ a={OrgPermissionSubjects.Gateway}+ >+ {(isAllowed) => (+ <Field className="mb-4">+ <FieldLabel>Gateway</FieldLabel>+ {isAllowed ? (+ <GatewayPicker+ isDisabled={!isAllowed}+ value={{ gatewayId: gatewayId ?? null, gatewayPoolId: gatewayPoolId ?? null }}+ onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {+ setValue("gatewayId", newGwId, { shouldDirty: true });+ setValue("gatewayPoolId", newPoolId, { shouldDirty: true });+ }}+ />+ ) : (+ <Tooltip>+ <TooltipTrigger asChild>+ <div>+ <GatewayPicker+ isDisabled={!isAllowed}+ value={{+ gatewayId: gatewayId ?? null,+ gatewayPoolId: gatewayPoolId ?? null+ }}+ onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {+ setValue("gatewayId", newGwId, { shouldDirty: true });+ setValue("gatewayPoolId", newPoolId, { shouldDirty: true });+ }}+ />+ </div>+ </TooltipTrigger>+ <TooltipContent>+ Restricted access. You don't have permission to attach gateways to+ resources.+ </TooltipContent>+ </Tooltip>+ )}+ </Field>+ )}+ </OrgPermissionCan>+ <Controller+ name="method"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel>+ Method+ <Tooltip>+ <TooltipTrigger asChild>+ <Info />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ {`The method you would like to use to connect with ${+ APP_CONNECTION_MAP[AppConnection.PaloAltoNetworks].name+ }. This field cannot be changed after creation.`}+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Select disabled={isUpdate} value={value} onValueChange={(val) => onChange(val)}>+ <SelectTrigger className="w-full" isError={Boolean(error)}>+ <SelectValue placeholder="Select a method..." />+ </SelectTrigger>+ <SelectContent position="popper">+ {Object.values(PaloAltoNetworksConnectionMethod).map((method) => {+ return (+ <SelectItem value={method} key={method}>+ {getAppConnectionMethodDetails(method).name}+ </SelectItem>+ );+ })}+ </SelectContent>+ </Select>+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ <Tabs value={selectedTab} onValueChange={setSelectedTab} className="mb-4">+ <TabsList variant={scopeVariant}>+ <TabsTrigger value="configuration">Configuration</TabsTrigger>+ <TabsTrigger value="ssl">SSL</TabsTrigger>+ </TabsList>+ <TabsContent value="configuration">+ <Controller+ name="credentials.hostname"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel htmlFor="credentials-hostname">+ Hostname+ <Tooltip>+ <TooltipTrigger asChild>+ <Info />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ The IP address or hostname of the management interface of the firewall or+ Panorama.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Input+ id="credentials-hostname"+ value={value}+ onChange={(e) => onChange(e.target.value)}+ placeholder="e.g. firewall.example.com"+ isError={Boolean(error?.message)}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ <div className="grid grid-cols-2 gap-2">+ <Controller+ name="credentials.username"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel htmlFor="credentials-username">+ Username+ <Tooltip>+ <TooltipTrigger asChild>+ <Info />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ A PAN-OS administrator with XML API access to configuration, operational+ requests, commit, and import. Use an account dedicated to Infisical.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Input+ id="credentials-username"+ value={value}+ onChange={(e) => onChange(e.target.value)}+ placeholder="admin"+ isError={Boolean(error?.message)}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ <Controller+ name="credentials.password"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel htmlFor="app-connection-palo-alto-networks-password">+ Password+ <Tooltip>+ <TooltipTrigger asChild>+ <Info />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ The password of the PAN-OS administrator.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <SecretInput+ aria-describedby={+ error ? "app-connection-palo-alto-networks-password-error" : undefined+ }+ id="app-connection-palo-alto-networks-password"+ isError={Boolean(error)}+ value={value}+ onChange={(e) => onChange(e.target.value)}+ />+ <FieldError+ id="app-connection-palo-alto-networks-password-error"+ errors={[error]}+ />+ </Field>+ )}+ />+ </div>+ <Controller+ name="credentials.port"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel htmlFor="credentials-port">+ Port <span className="text-muted">(optional)</span>+ <Tooltip>+ <TooltipTrigger asChild>+ <Info />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ The HTTPS port of the management interface. Defaults to 443.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <Input+ id="credentials-port"+ type="number"+ value={value ?? ""}+ onChange={(e) => onChange(e.target.value ? Number(e.target.value) : undefined)}+ placeholder="443"+ isError={Boolean(error?.message)}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ </TabsContent>+ <TabsContent value="ssl">+ <Controller+ name="credentials.sslCertificate"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field className="mb-4">+ <FieldLabel htmlFor="ssl-certificate">+ SSL Certificate <span className="text-muted">(optional)</span>+ </FieldLabel>+ <TextArea+ id="ssl-certificate"+ className="h-[3.6rem] resize-none!"+ {...field}+ placeholder="-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----"+ isError={Boolean(error?.message)}+ />+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ <Controller+ name="credentials.sslRejectUnauthorized"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field>+ <Field orientation="horizontal">+ <FieldContent>+ <Label htmlFor="ssl-reject-unauthorized">Reject Unauthorized</Label>+ <FieldDescription>+ When on, Infisical connects only if the management interface presents a+ trusted certificate. PAN-OS uses a self-signed certificate by default, so+ add its CA certificate above or turn this off.+ </FieldDescription>+ </FieldContent>+ <Toggle+ aria-invalid={Boolean(error)}+ id="ssl-reject-unauthorized"+ variant={scopeVariant}+ checked={value}+ onCheckedChange={onChange}+ />+ </Field>+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ </TabsContent>+ </Tabs>+ <AppConnectionFormFooter+ submitLabel={isUpdate ? "Update Credentials" : "Connect to Palo Alto Networks"}+ />+ </form>+ </FormProvider>+ );+};