Dart
Dart
Load a PFX from an Encoded String
See more PFX/P12 Examples
Demonstrates Pfx.LoadPfxEncoded, which decodes text using a named binary encoding (such as base64) and loads the resulting bytes as a PFX / PKCS#12 container.
Background. This is useful when the PKCS#12 data has been transported or stored as printable text, such as base64.
Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final pfx = CkPfx();
// The PFX password should come from a secure source rather than being hard-coded.
final password = 'myPfxPassword';
// Decode the base64 text into PFX / PKCS#12 bytes and load them. Common encodings include base64
// and hex.
final encodedPfx = 'MIIKrAIBAzCCCm...base64-encoded-pfx...';
try {
pfx.loadPfxEncoded(encodedPfx, 'base64', password);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('Loaded ${pfx.numCerts} certificate(s).');
}