getCertificates method

  1. @override
Future<List<X509Certificate>> getCertificates({
  1. bool includeSystemCertificates = true,
  2. bool includeUserCertificates = true,
})
override

Loads all certificates from the native certificate store of the current platform.

Implementation

@override
Future<List<X509Certificate>> getCertificates({
  bool includeSystemCertificates = true,
  bool includeUserCertificates = true,
}) async {
  final result = await methodChannel
      .invokeMethod<List<dynamic>>('getCertificates', <String, dynamic>{
        'includeSystemCertificates': includeSystemCertificates,
        'includeUserCertificates': includeUserCertificates,
      });

  if (result == null) {
    return [];
  }

  return result.map((item) {
    final map = item as Map<Object?, Object?>;
    return NativeCertificate(
      der: map['der'] as Uint8List,
      sha1: map['sha1'] as Uint8List,
      subject: map['subject'] as String,
      issuer: map['issuer'] as String,
      startValidity: DateTime.fromMillisecondsSinceEpoch(
        map['startValidity'] as int,
      ),
      endValidity: DateTime.fromMillisecondsSinceEpoch(
        map['endValidity'] as int,
      ),
    );
  }).toList();
}