extractRevocationInfo function
Extracts OCSP and CRL distribution URLs from the supplied X.509 extension map.
extensions is the map produced by parseX509 where keys are dotted OID
strings and values are the raw DER extension value bytes. Malformed or
unsupported extensions are ignored.
Implementation
RevocationInfo extractRevocationInfo(Map<String, List<int>> extensions) {
final ocsp = <Uri>[];
final crls = <Uri>[];
final aiaRaw = extensions[_authorityInfoAccessOid];
if (aiaRaw != null) {
try {
final aia = _parseAuthorityInfoAccess(Uint8List.fromList(aiaRaw));
for (final d in aia.descriptions) {
if (d.accessMethod == _idAdOcsp && d.accessLocation != null) {
final uri = Uri.tryParse(d.accessLocation!);
if (uri != null) {
ocsp.add(uri);
}
}
}
} catch (_) {
// Ignore malformed AIA extension.
}
}
final crlRaw = extensions[_crlDistributionPointsOid];
if (crlRaw != null) {
try {
final crlUrls =
_extractCrlDistributionPointUrls(Uint8List.fromList(crlRaw));
crls.addAll(crlUrls);
} catch (_) {
// Ignore malformed CRLDistributionPoints extension.
}
}
return RevocationInfo(ocspUrls: ocsp, crlUrls: crls);
}