To obtain the public key from a signed Autenticode .Net library, use the following code:
Assembly assembly = Assembly.LoadFrom("dll_file_name"); X509Certificate certificate = assembly.ManifestModule.GetSignerCertificate(); byte[] publicKey = certificate.GetPublicKey();
But this will only work if the certificate has been installed in trusted root certification authorities. Otherwise, GetSignerCertificate() returns null.
The second method allows you to obtain a certificate, even if it is not located in trusted root certification authorities.
X509Certificate executingCert = X509Certificate.CreateFromSignedFile("dll_file_name"); byte[] publicKey = certificate.GetPublicKey();
Yoh deadfall
source share