getCertificateChain method

List<List<int>>? getCertificateChain()

Gets the certificate chain in raw bytes.

//Load the certificate from the file
final PdfCertificate certificate =
    PdfCertificate(File('PDF.pfx').readAsBytesSync(), 'password');
//Get the certificate chain
List<List<int>>? certificateChain = certificate.getCertificateChain();

Implementation

List<List<int>>? getCertificateChain() {
  List<List<int>>? certificateChain;
  try {
    certificateChain = <List<int>>[];
    _pkcsCertificate.getChainCertificates().forEach((X509Certificates entry) {
      final List<int> certificateBytes =
          entry.certificate!.c!.getDerEncoded()!;
      certificateChain!.add(certificateBytes);
    });
  } catch (e) {
    return null;
  }
  return certificateChain;
}