相关疑难解决方法(0)

如何在Windows上为代码签名创建自签名证书?

如何使用Windows SDK中的工具为代码签名创建自签名证书?

security code-signing

212
推荐指数
5
解决办法
15万
查看次数

从.NET中的Authenticode签名文件中获取时间戳

我们需要验证二进制文件是否使用数字签名(Authenticode)正确签名.这可以通过signtool.exe轻松实现.但是,我们需要一种自动方式来验证签名者名称和时间戳.这在使用CryptQueryObject()API的本机C++中是可行的,如以下精彩示例所示:如何从Authenticode签名的可执行文件获取信息

然而,我们生活在一个托管的世界:)因此寻找相同问题的C#解决方案.直接的方法是pInvoke Crypt32.dll,一切都完成了.但是System.Security.Cryptography.X509CertificatesNamespace中有类似的托管API .X509Certificate2类似乎提供了一些信息但没有时间戳.现在我们来到原始问题,我们如何才能在C Sharp中获得数字签名的时间戳?

.net c# certificate signature authenticode

21
推荐指数
3
解决办法
1万
查看次数

从可执行文件中读取多个签名

我正在尝试编写从DLL或EXE读取签名(证书)的代码.大多数DLL或EXE只有一个签名,我的代码正确读取与此签名关联的所有证书.更具体地说,它读取签名证书,它是发行者(不是root),签名证书(带有时间戳)和它的发行者(不是root).我有2个C++和C#示例程序,它们都返回相同的证书.这是C#代码,C++是100倍长:)

static void Main(string[] args)
{
    X509Certificate2Collection collection = new X509Certificate2Collection();
    collection.Import(args[0]);
}
Run Code Online (Sandbox Code Playgroud)

但是有一些DLL有2个签名,如文件属性/数字签名所示,例如C:\ Program Files(x86)\ Microsoft SQL Server\80\Tools\Binn\msvcr71.dll:

msvcr71.dll的文件属性和数字签名

对于此DLL,我的代码只读取与第一个签名关联的证书.

我也尝试使用signtool,它返回与我的代码相同的信息:first cert(带有它的路径)和counterignature(带有它的路径).但最后还要注意错误.

C:\Windows>signtool verify /d /v "C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\msvcr71.dll"

Verifying: C:\Program Files (x86)\Microsoft SQL Server\80\Tools\Binn\msvcr71.dll
Signature Index: 0 (Primary Signature)
Hash of file (sha1): 33BBCCF6326276B413A1ECED1BF7842A6D1DDA07

Signing Certificate Chain:
Issued to: Microsoft Root Certificate Authority
Issued by: Microsoft Root Certificate Authority
Expires:   Sun May 09 19:28:13 2021
SHA1 hash: CDD4EEAE6000AC7F40C3802C171E30148030C072

    Issued to: Microsoft Code Signing PCA
    Issued by: Microsoft …
Run Code Online (Sandbox Code Playgroud)

c++ signatures authenticode

14
推荐指数
3
解决办法
4754
查看次数

如何使用时间戳正确地进行双重签名?

我有两个代码签名证书(一个SHA-1,一个SHA-256),我想将它们应用于同一个文件.我试图附加SHA-256证书,但这失败了:

:: Signs with the SHA-1 certificate
signtool sign /sha1 8f52fa9db30525dfabb35b08bd1966693a30eccf /t http://timestamp.verisign.com/scripts/timestamp.dll my_app_here.exe
:: Signs with the SHA-2 certificate
signtool sign /sha1 8b0026ecbe5bf245993b26e164f02e1313579e47 /as /t http://timestamp.verisign.com/scripts/timestamp.dll my_app_here.exe
Run Code Online (Sandbox Code Playgroud)

这失败并出现错误:

Done Adding Additional Store
SignTool Error: SignedCode::Sign returned error: 0x80070057
        The parameter is incorrect.
SignTool Error: An error occurred while attempting to sign: my_app_here.exe
Run Code Online (Sandbox Code Playgroud)

如果从第二个命令中删除时间戳URL,则签名成功完成,但SHA-2签名没有时间戳.(我是否在第一个签名上加上时间戳没有效果)

这里的目的是允许某人使用更强大的证书验证应用程序,如果他们在支持此功能的操作系统上,但是为了避免在不支持更强版本的操作系统(Vista,XP)上验证失败.

这种事情甚至可能吗?

code-signing authenticode code-signing-certificate verisign

11
推荐指数
1
解决办法
5919
查看次数