toPem method

String toPem()

A PEM bundle with provenance comments - the cache / hand-off format PdfEuTrustListSnapshot.fromPem and PdfTrustStore.addPem read.

Implementation

String toPem() {
  final out = StringBuffer()
    ..writeln('# EU trusted list anchors (qualified CA services)')
    ..writeln('# fetched-at: ${fetchedAt.toUtc().toIso8601String()}');
  if (lotlSequenceNumber != null) {
    out.writeln('# lotl-sequence: $lotlSequenceNumber');
  }
  if (lotlIssued != null) {
    out.writeln('# lotl-issued: ${lotlIssued!.toUtc().toIso8601String()}');
  }
  if (lotlNextUpdate != null) {
    out.writeln(
        '# lotl-next-update: ${lotlNextUpdate!.toUtc().toIso8601String()}');
  }
  if (expires != null) {
    out.writeln('# expires: ${expires!.toUtc().toIso8601String()}');
  }
  for (final entry in problems.entries) {
    out.writeln('# skipped ${entry.key}: '
        '${entry.value.replaceAll('\n', ' ')}');
  }
  for (final e in entries) {
    out
      ..writeln()
      ..writeln('# ${e.territory}: ${e.serviceName.replaceAll('\n', ' ')}')
      ..writeln('# type: ${e.serviceType}')
      ..write(pemEncode('CERTIFICATE', e.certificate));
  }
  return out.toString();
}