Is is possible to sign a binary via .NET code? (no

2019-03-31 13:31发布

I've the following requirement, sign a binary with a certificate, but without signtool.exe; the idea would be to do it via code.

Do you know if it's possible?

1条回答
地球回转人心会变
2楼-- · 2019-03-31 14:06

You will need to use the SignerSign or SignerSignEx functions that are exported from mssign32.dll.

To use these, you'll need to define managed versions of the SIGNER_SUBJECT_INFO, SIGNER_FILE_INFO, SIGNER_CERT, SIGNER_SIGNATURE_INFO, etc. structs, then correctly specify the P/Invoke signature for the native method.

Halfway through this blog post, there is a C++ example of calling SignerSignEx; Mark has ported it to C# in this StackOverflow answer.

查看更多
登录 后发表回答