Thanks,
Rob
// Search for the signer certificate in the temporary
// certificate store.
CertInfo.Issuer = pSignerInfo->Issuer;
CertInfo.SerialNumber = pSignerInfo->SerialNumber;
pCertContext = CertFindCertificateInStore(hStore,
ENCODING,
0,
CERT_FIND_SUBJECT_CERT,
(PVOID)&CertInfo,
NULL);
if (!pCertContext)
{
_tprintf(_T("CertFindCertificateInStore failed with %x\n"),
GetLastError());
__leave;
}
// Print Signer certificate information.
_tprintf(_T("Signer Certificate:\n\n"));
PrintCertificateInfo(pCertContext);
_tprintf(_T("\n"));
if (!CryptVerifyCertificateSignature(NULL, X509_ASN_ENCODING |
PKCS_7_ASN_ENCODING,
(BYTE*)pCertContext->pbCertEncoded, pCertContext->cbCertEncoded,
&pCertContext->pCertInfo->SubjectPublicKeyInfo))
{
DWORD err= GetLastError();
}
--
- hao
HCRYPTMSG hMsg=NULL;
PCCERT_CONTEXT pvercert;
DWORD dn = 0;
DWORD dwcontenttype = 0;
HCERTSTORE hCertStore = NULL;
if (!CryptQueryObject(CERT_QUERY_OBJECT_FILE, buffer,
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,
CERT_QUERY_FORMAT_FLAG_BINARY,
0, NULL, &dwcontenttype, NULL, &hCertStore,
&hMsg, NULL))
{
btrusted = false;
err= GetLastError();
}
CryptMsgGetParam(hMsg, CMSG_SIGNER_CERT_INFO_PARAM, 0, NULL, &dn);
PCERT_INFO pSignerInfo = (PCERT_INFO)(new char[dn]);
CryptMsgGetParam(hMsg, CMSG_SIGNER_CERT_INFO_PARAM, 0, pSignerInfo, &dn);
err= GetLastError();
But the SubjectPublicKeyInfo member of the pSignerInfo struct is
uninitialised as are several other members. So supplying
CryptVerifyCertificateSignature with pSignerInfo->SubjectPublicKeyInfo as
the last argument is obviously no good.
If anyone knows how to obtain the public key from the signer's certificate
I'd be very grateful.
Thanks,
Rob
--
"Hao Zhuang [MSFT]" <HaoZhu...@discussions.microsoft.com> wrote in
message news:F8B70C27-DC3C-4E78...@microsoft.com...
if you wish to verify the file signatures, your best bet would be
WinVerityTrust(). you can use many flags to prevent WVT from doing the things
you dont want it to do. i'm not the expert of code signing though.
if you wish to verify the validity of the signer certificates, which was
what i first thought you were doing from your initially posted code, you
should use the public key of the signer of the signer cert to call
CryptVerifyCertificateSignature().
hope this helps.
Rob