Class Pkcs12ImportSpec

java.lang.Object
co.ankatech.ankasecure.sdk.model.Pkcs12ImportSpec

public class Pkcs12ImportSpec extends Object

DTO used to import private keys (and certificate chains) from a PKCS#12 / .p12 container supplied as a Base64 string.

Multi-Key Support

PKCS#12 files may contain multiple private keys. Use kidStrategy to control how kids are generated:

  • AUTO (default): System generates kids as {kid}-{alias}
  • MANUAL: Provide explicit alias-to-kid mappings via kidMappings

Certificate Validation

Server validates X.509 certificates based on configured mode (STRICT, IMPORT_ONLY, SKIP). Override via validationMode if server configuration allows.

Notes

  • The file must be encoded with the binary form of PKCS#12, not PEM.
  • An empty password is represented by the empty string "".
  • The SDK automatically wipes the Base64 string from memory once the HTTP call completes.

Example (simple)


 Pkcs12ImportSpec spec = new Pkcs12ImportSpec()
         .setKid("bank-tls-key-2025")
         .setP12FileBase64(base64Data)
         .setP12Password("S3cret!");

 Pkcs12ImportResult result = sdk.importPrivateKeyPkcs12(spec);
 System.out.println("Imported: " + result.getTotalImported() + " keys");
 
Author:
Javier Galindo