loadPkcs12Certificate static method

Future<CPDFCertificateInfo?> loadPkcs12Certificate(
  1. String path,
  2. String password
)

Loads certificate metadata from a PKCS#12 file.

Returns null when the file cannot be loaded or its certificate is not valid. The returned CPDFCertificateInfo.isTrusted value reflects the application trust store.

example:

final certificate = await ComPDFKit.loadPkcs12Certificate(
  '/path/to/certificate.p12',
  'certificate-password',
);
if (certificate != null) {
  print('Subject: ${certificate.subject}');
  print('Trusted: ${certificate.isTrusted}');
}

Implementation

static Future<CPDFCertificateInfo?> loadPkcs12Certificate(
    String path, String password) async {
  final result = await _methodChannel.invokeMethod(
    'load_pkcs12_certificate',
    <String, String>{'path': path, 'password': password},
  );
  if (result is! Map) return null;
  return CPDFCertificateInfo.fromJson(Map<String, dynamic>.from(result));
}