public static AsymmetricAlgorithm GetAnyPublicKey(this X509Certificate2 c) { AsymmetricAlgorithm a; a = c.GetRSAPublicKey(); if (a != null) { return(a); } a = c.GetDSAPublicKey(); if (a != null) { return(a); } a = c.GetECDsaPublicKey(); if (a != null) { return(a); } throw new NotSupportedException(SecurityResources.GetResourceString("NotSupported_KeyAlgorithm")); }