fromPem static method

List<SSHKeyPair> fromPem(
  1. String pemText, [
  2. String? passphrase
])

Implementation

static List<SSHKeyPair> fromPem(String pemText, [String? passphrase]) {
  final pem = SSHPem.decode(pemText);
  switch (pem.type) {
    case 'OPENSSH PRIVATE KEY':
      final pairs = OpenSSHKeyPairs.decode(pem.content);
      return pairs.getPrivateKeys(passphrase);
    case 'RSA PRIVATE KEY':
      final pair = RsaKeyPair.decode(pem);
      return [pair.getPrivateKeys(passphrase)];
    default:
      throw UnsupportedError('Unsupported key type: ${pem.type}');
  }
}