Advertisement
FoKycHuK

GetAnyPublicKey

Jan 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. public static AsymmetricAlgorithm GetAnyPublicKey(this X509Certificate2 c)
  2. {
  3.     AsymmetricAlgorithm a;
  4.  
  5.     a = c.GetRSAPublicKey();
  6.     if (a != null)
  7.         return a;
  8.  
  9.     a = c.GetDSAPublicKey();
  10.     if (a != null)
  11.         return a;
  12.  
  13.     a = c.GetECDsaPublicKey();
  14.     if (a != null)
  15.         return a;
  16.  
  17.     throw new NotSupportedException(SecurityResources.GetResourceString("NotSupported_KeyAlgorithm"));
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement