Sample code for 30+ languages & platforms
Dart

Load PFX/P12 from a Base64 Encoded PFX File

See more PFX/P12 Examples

Demonstrates how to call LoadPfxEncoded.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final bd = CkBinData();

  try {
    bd.loadFile('qa_data/pfx/cert_test123.pfx');
  } on ChilkatException {
    print('Failed to load PFX file.');
    return;
  }

  // Get the bytes contained in the PFX in base64 format:
  final strBase64 = bd.getEncoded('base64');

  // The base64 looks like this:  "MIIbEAIBAzCCGswGCSqGSIb3DQEHAaCCGr0Eghq5MIIatTCCBg..."
  print(strBase64);

  final pfx = CkPfx();

  // Load the PFX from the base64 string
  final password = 'test123';
  try {
    pfx.loadPfxEncoded(strBase64, 'base64', password);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  print('success');
}