I'm signing a dot net exe using
signcode.exe with an spc/pvk combo
The file needs to read its own Public Key at runtime in order to verify some data. I've gone down a number of different avenues.
I've tried
X509Certificate executingCert = X509Certificate.CreateFromSignedFile(exe);
executingCert is then null. I'm guessing signcode isn't creating an X509 signed file, though if there's a switch to change that I'm happy to go that way.
edited Turns out the above does work.... I had my null check backwards (!= != ==) :)
Assembly asm = Assembly.GetExecutingAssembly();
string exe = asm.Location;
X509Certificate executingCert = X509Certificate.CreateFromSignedFile(exe);
if (executingCert != null)
{
Console.WriteLine("Assembly is signed");
byte[] assemblyKey = executingCert.GetPublicKey();
}