crypt32: CertGetIssuerCertificateFromStore must return error for self-signed certificates.

This commit is contained in:
Bruno Jesus 2014-07-22 20:43:06 -03:00 committed by Alexandre Julliard
parent 69d198a9eb
commit 7a40fdbf8c
4 changed files with 8 additions and 5 deletions

View File

@ -1883,6 +1883,12 @@ PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore(HCERTSTORE hCertStore,
CertFreeCertificateContext(ret);
ret = NULL;
}
if (CRYPT_IsCertificateSelfSigned(pSubjectContext))
{
CertFreeCertificateContext(ret);
ret = NULL;
SetLastError(CRYPT_E_SELF_SIGNED);
}
}
TRACE("returning %p\n", ret);
return ret;

View File

@ -265,7 +265,7 @@ typedef struct _CertificateChain
LONG ref;
} CertificateChain;
static BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert)
BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert)
{
PCERT_EXTENSION ext;
DWORD size;

View File

@ -337,6 +337,7 @@ WINECRYPT_CERTSTORE *CRYPT_FileNameOpenStoreA(HCRYPTPROV hCryptProv,
WINECRYPT_CERTSTORE *CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
DWORD dwFlags, const void *pvPara) DECLSPEC_HIDDEN;
WINECRYPT_CERTSTORE *CRYPT_RootOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags) DECLSPEC_HIDDEN;
BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert) DECLSPEC_HIDDEN;
/* Allocates and initializes a certificate chain engine, but without creating
* the root store. Instead, it uses root, and assumes the caller has done any

View File

@ -1728,9 +1728,7 @@ static void testGetIssuerCert(void)
SetLastError(0xdeadbeef);
flags = 0;
parent = CertGetIssuerCertificateFromStore(store, cert3, NULL, &flags);
todo_wine
ok(!parent, "Expected NULL\n");
todo_wine
ok(GetLastError() == CRYPT_E_SELF_SIGNED,
"Expected CRYPT_E_SELF_SIGNED, got %08X\n", GetLastError());
CertFreeCertificateContext(child);
@ -1747,9 +1745,7 @@ todo_wine
ok(cert1 != NULL, "CertEnumCertificatesInStore should have worked\n");
SetLastError(0xdeadbeef);
parent = CertGetIssuerCertificateFromStore(store, cert1, NULL, &flags);
todo_wine
ok(!parent, "Expected NULL\n");
todo_wine
ok(GetLastError() == CRYPT_E_SELF_SIGNED,
"Expected CRYPT_E_SELF_SIGNED, got %08X\n", GetLastError());
CertCloseStore(store, 0);