Ily*_*lya 6 device-driver digital-signature setupapi windows-7 driver-signing
在Windows 7上通过DpInst安装已签名的驱动程序(即使用正确签名的.CAB)时,除非它是WHQL签名的驱动程序,否则无法以静默方式安装它.如果您以非静默模式运行DpInst,它将提示您信任"发布者".如果您以静默模式运行DpInst,它将失败并显示与签名相关的错误代码(类似于0x800b0109 - 请检查您的setupapi.app.log).
虽然ilya的答案很好,但Windows 7上的解决方案更加容易.以下命令将证书部署到当前用户和系统受信任的发布者证书存储区.它需要管理权限,由Microsoft提供.
certutil.exe -addstore TrustedPublisher cert.cer
Run Code Online (Sandbox Code Playgroud)
我确认这适用于Windows 7 64位,以便在不提示用户的情况下部署已签名但未经WHQL认证的驱动程序.
似乎在XP上你仍然需要使用WHQL认证的驱动程序,以避免安装提示.
对于Windows XP,您需要从Microsoft下载Windows Server 2003管理工具包并提取certutil.exe和certadm.dll.然后上面的命令也适用于XP.
管理工具包:http://www.microsoft.com/download/en/details.aspx? DisplayLang = en&id = 16770
请注意,提取的msi文件可以通过7-zip进行检查,因此您无需安装它即可获得所需的exe和dll.
最简单的方法是将签名证书添加到 TrustedPublishers。您可以通过编程来完成(win32Exception 的实现留给读者作为练习):
#include <windows.h>
#include <wincrypt.h>
#include "win32exception.h"
void InstallTrustedPublisherCertificate(LPCTSTR CertificateFilePath)
{
DWORD dwContentType;
PCCERT_CONTEXT pCertContext = NULL;
if (!CryptQueryObject(
CERT_QUERY_OBJECT_FILE,
CertificateFilePath,
CERT_QUERY_CONTENT_FLAG_ALL,
CERT_QUERY_FORMAT_FLAG_ALL,
0,
NULL,
&dwContentType,
NULL,
NULL,
NULL,
(const void **)&pCertContext))
throw win32exception("CryptQueryObject");
if (dwContentType != CERT_QUERY_CONTENT_CERT)
throw exception("Incorrect content type of crypto object.");
__try
{
HCERTSTORE hCertStore = CertOpenStore(
CERT_STORE_PROV_SYSTEM,
0,
0,
CERT_STORE_OPEN_EXISTING_FLAG |
CERT_SYSTEM_STORE_CURRENT_USER,
_T("TrustedPublisher"));
if (hCertStore == NULL)
throw win32exception("CertOpenStore");
__try
{
if (CertAddCertificateContextToStore(hCertStore, pCertContext, CERT_STORE_ADD_NEWER, NULL))
{
// Added certificate to TrustedPublisher store.
}
else
{
DWORD err = GetLastError();
if (err == CRYPT_E_EXISTS)
{
// Certificate already exists in TrustedPublisher store.
}
else
throw win32exception("CertAddCertificateContextToStore", err);
}
}
__finally
{
CertCloseStore (hCertStore, 0);
}
}
__finally
{
CertFreeCertificateContext(pCertContext);
}
}
Run Code Online (Sandbox Code Playgroud)