From 44a80ab1520d2434fcd01cbeadcfcef97f6c9ce2 Mon Sep 17 00:00:00 2001
From: hhftechnologies
Date: Sun, 1 Mar 2026 13:23:10 +0530
Subject: [PATCH 1/3] add legacy_p12 option for PKCS#12 generation
add a legacy_p12 boolean to CreateClientRequest (backend model and frontend type) to support generating PKCS#12 files with legacy encryption for iOS/older device compatibility. CertGenerator now selects pkcs12.Legacy when legacy_p12 is true (defaults to Modern otherwise). UI: add a checkbox to the client cert creation dialog and initialize form state to include legacy_p12.
---
models/mtls.go | 1 +
services/cert_generator.go | 6 +++++-
ui/src/components/security/ClientCertList.tsx | 15 ++++++++++++++-
ui/src/types/mtls.ts | 1 +
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/models/mtls.go b/models/mtls.go
index fc0fce39..aa933326 100644
--- a/models/mtls.go
+++ b/models/mtls.go
@@ -47,6 +47,7 @@ type CreateClientRequest struct {
Name string `json:"name" binding:"required"`
ValidityDays int `json:"validity_days"` // Default: 730 (2 years)
P12Password string `json:"p12_password" binding:"required"`
+ LegacyP12 bool `json:"legacy_p12"` // Use legacy encryption for iOS/older device compatibility
}
// UpdateMTLSConfigRequest represents the request to update resource mTLS settings
diff --git a/services/cert_generator.go b/services/cert_generator.go
index 90afe2b2..d8283925 100644
--- a/services/cert_generator.go
+++ b/services/cert_generator.go
@@ -246,7 +246,11 @@ func (cg *CertGenerator) GenerateClientCert(req models.CreateClientRequest) (*mo
}
// Generate PKCS#12 (.p12) file
- p12Data, err := pkcs12.Modern.Encode(clientKey, clientCert, []*x509.Certificate{caCert}, req.P12Password)
+ encoder := pkcs12.Modern
+ if req.LegacyP12 {
+ encoder = pkcs12.Legacy
+ }
+ p12Data, err := encoder.Encode(clientKey, clientCert, []*x509.Certificate{caCert}, req.P12Password)
if err != nil {
return nil, fmt.Errorf("failed to generate PKCS#12: %w", err)
}
diff --git a/ui/src/components/security/ClientCertList.tsx b/ui/src/components/security/ClientCertList.tsx
index d8e41533..0fda631a 100644
--- a/ui/src/components/security/ClientCertList.tsx
+++ b/ui/src/components/security/ClientCertList.tsx
@@ -5,6 +5,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
+import { Checkbox } from '@/components/ui/checkbox'
import { Badge } from '@/components/ui/badge'
import { Alert, AlertDescription } from '@/components/ui/alert'
import {
@@ -110,7 +111,7 @@ export function ClientCertList() {
if (client) {
setNewClientId(client.id)
setIsCreateOpen(false)
- setFormData({ name: '', validity_days: 730, p12_password: '' })
+ setFormData({ name: '', validity_days: 730, p12_password: '', legacy_p12: false })
setConfirmPassword('')
}
}
@@ -243,6 +244,18 @@ export function ClientCertList() {
Default: 730 days (2 years)
+
+
+ setFormData({ ...formData, legacy_p12: checked === true })
+ }
+ />
+
+