Commit 7a40fdbf authored by Bruno Jesus's avatar Bruno Jesus Committed by Alexandre Julliard

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

parent 69d198a9
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment