Exemplo n.º 1
0
 public static AsymmetricCipherKeyPair ReadPrivateKey(byte[] privateKeyBuffer, PasswordFinder password = null)
 {
     try
     {
         if (privateKeyBuffer == null)
         {
             throw new Exception("The key buffer is null.");
         }
         var reader = new StreamReader(new MemoryStream(privateKeyBuffer));
         return((AsymmetricCipherKeyPair) new PemReader(reader, password).ReadObject());
     }
     catch (Exception ex)
     {
         throw new Exception($"The file {privateKeyBuffer} is not a private key.", ex);
     }
 }
Exemplo n.º 2
0
 public static AsymmetricCipherKeyPair ReadPrivateKey(string privateKeyFile, PasswordFinder password = null) => ReadPrivateKey(File.ReadAllBytes(privateKeyFile), password);