readPemFile static method

Future<IcpPem> readPemFile(
  1. String path
)

Implementation

static Future<IcpPem> readPemFile(String path) async {
  File pemFile = File(path);
  if (!await pemFile.exists()) {
    throw Exception('PEM file does not exist at the specified path.');
  }

  String content = await pemFile.readAsString();
  final List<String> result = content
      .split('\n')
      .where((line) => line.isNotEmpty && !line.startsWith('-'))
      .toList();

  return IcpPem(result[0], result[1]);
}