mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 04:20:56 +00:00
crypt32: Added a test showing that CertGetCertificateChain should use global store.
This commit is contained in:
parent
d5e648dc2f
commit
8ef3a14226
|
@ -237,6 +237,97 @@ static const BYTE google[] = {
|
|||
0xd1,0xbd,0xd7,0x95,0x22,0x43,0x7a,0x06,0x7b,0x4e,0xf6,0x37,0x8e,0xa2,0xb9,
|
||||
0xcf,0x1f,0xa5,0xd2,0xbd,0x3b,0x04,0x97,0x39,0xb3,0x0f,0xfa,0x38,0xb5,0xaf,
|
||||
0x55,0x20,0x88,0x60,0x93,0xf2,0xde,0xdb,0xff,0xdf };
|
||||
/* *.winehq.org cert */
|
||||
static const BYTE winehq_org[] = {
|
||||
0x30,0x82,0x05,0x2a,0x30,0x82,0x04,0x12,0xa0,0x03,0x02,0x01,0x02,0x02,0x03,
|
||||
0x0c,0x35,0xd0,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,
|
||||
0x05,0x05,0x00,0x30,0x3c,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,
|
||||
0x02,0x55,0x53,0x31,0x17,0x30,0x15,0x06,0x03,0x55,0x04,0x0a,0x13,0x0e,0x47,
|
||||
0x65,0x6f,0x54,0x72,0x75,0x73,0x74,0x2c,0x20,0x49,0x6e,0x63,0x2e,0x31,0x14,
|
||||
0x30,0x12,0x06,0x03,0x55,0x04,0x03,0x13,0x0b,0x52,0x61,0x70,0x69,0x64,0x53,
|
||||
0x53,0x4c,0x20,0x43,0x41,0x30,0x1e,0x17,0x0d,0x31,0x33,0x30,0x35,0x32,0x32,
|
||||
0x30,0x33,0x35,0x36,0x30,0x39,0x5a,0x17,0x0d,0x31,0x34,0x30,0x35,0x32,0x35,
|
||||
0x30,0x37,0x33,0x34,0x31,0x34,0x5a,0x30,0x81,0xbb,0x31,0x29,0x30,0x27,0x06,
|
||||
0x03,0x55,0x04,0x05,0x13,0x20,0x30,0x6d,0x4a,0x75,0x76,0x31,0x74,0x2d,0x31,
|
||||
0x43,0x46,0x79,0x70,0x51,0x6b,0x79,0x54,0x5a,0x77,0x66,0x76,0x6a,0x48,0x48,
|
||||
0x42,0x41,0x62,0x6e,0x55,0x6e,0x64,0x47,0x31,0x13,0x30,0x11,0x06,0x03,0x55,
|
||||
0x04,0x0b,0x13,0x0a,0x47,0x54,0x39,0x38,0x33,0x38,0x30,0x30,0x31,0x31,0x31,
|
||||
0x31,0x30,0x2f,0x06,0x03,0x55,0x04,0x0b,0x13,0x28,0x53,0x65,0x65,0x20,0x77,
|
||||
0x77,0x77,0x2e,0x72,0x61,0x70,0x69,0x64,0x73,0x73,0x6c,0x2e,0x63,0x6f,0x6d,
|
||||
0x2f,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x73,0x2f,0x63,0x70,0x73,0x20,
|
||||
0x28,0x63,0x29,0x31,0x33,0x31,0x2f,0x30,0x2d,0x06,0x03,0x55,0x04,0x0b,0x13,
|
||||
0x26,0x44,0x6f,0x6d,0x61,0x69,0x6e,0x20,0x43,0x6f,0x6e,0x74,0x72,0x6f,0x6c,
|
||||
0x20,0x56,0x61,0x6c,0x69,0x64,0x61,0x74,0x65,0x64,0x20,0x2d,0x20,0x52,0x61,
|
||||
0x70,0x69,0x64,0x53,0x53,0x4c,0x28,0x52,0x29,0x31,0x15,0x30,0x13,0x06,0x03,
|
||||
0x55,0x04,0x03,0x0c,0x0c,0x2a,0x2e,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,
|
||||
0x72,0x67,0x30,0x82,0x01,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,
|
||||
0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0f,0x00,0x30,0x82,0x01,0x0a,
|
||||
0x02,0x82,0x01,0x01,0x00,0xc2,0x91,0x35,0xc7,0x67,0x32,0xf1,0x66,0x12,0x38,
|
||||
0x79,0xdb,0x02,0x11,0x95,0x89,0x1b,0x4a,0x6a,0x63,0x45,0x35,0x58,0x1b,0x57,
|
||||
0x8d,0xec,0x19,0x88,0xf5,0xa3,0x9e,0x6b,0xdb,0x07,0xfb,0x6e,0x29,0xe9,0xa9,
|
||||
0x14,0x07,0x8c,0x3a,0xc1,0xd7,0x88,0xcc,0xe4,0x55,0x79,0x6e,0x97,0xe9,0x93,
|
||||
0x88,0x9a,0x89,0xf9,0x31,0x0f,0x91,0x61,0xc2,0x9c,0xae,0x59,0x25,0x93,0x9a,
|
||||
0xc8,0xf9,0x28,0x7a,0x0f,0x0f,0x89,0x9a,0xda,0x46,0xbe,0xb2,0xdc,0x90,0x5b,
|
||||
0xd8,0x87,0xda,0xda,0xce,0x70,0x70,0x95,0x43,0x51,0xa0,0x21,0x22,0x54,0xab,
|
||||
0xa7,0x09,0xe1,0x81,0x09,0x8c,0x00,0x15,0x30,0x5a,0xa7,0x61,0x77,0xba,0x48,
|
||||
0x91,0xc6,0x94,0x90,0xdd,0x1a,0xf4,0x3f,0xa6,0x8a,0xb4,0x2f,0x98,0x16,0x0d,
|
||||
0x96,0x9f,0x0c,0x96,0x01,0x15,0xbc,0x74,0x7e,0x5c,0x4e,0xe3,0x95,0xae,0x00,
|
||||
0xf5,0x5b,0x88,0x0f,0xef,0x7c,0x1f,0xab,0x22,0xfe,0x95,0x42,0x1a,0xbd,0xee,
|
||||
0x23,0xca,0x5b,0x7f,0x4a,0xb0,0xbe,0x15,0x65,0xe2,0xce,0x02,0xc4,0xf6,0xb8,
|
||||
0xf3,0xd6,0x7e,0x75,0x5e,0x63,0x47,0x5d,0xc1,0xca,0xc3,0xc4,0x4a,0xf5,0x4d,
|
||||
0x66,0x34,0x03,0xf8,0xf4,0x54,0x7d,0x6b,0x54,0x2f,0x17,0x7c,0x39,0x13,0x78,
|
||||
0x09,0x9e,0xd0,0x9c,0x51,0x02,0x11,0x9d,0xa7,0x53,0x60,0xdd,0x62,0x2b,0xee,
|
||||
0xb0,0xd1,0xf2,0x1a,0x5c,0xdc,0xa7,0x58,0xc2,0xfa,0x29,0xcf,0xf3,0xc9,0xe9,
|
||||
0xae,0xe8,0x70,0x60,0x99,0xc7,0x30,0xdd,0x1c,0xda,0x32,0xc0,0x45,0xa5,0x48,
|
||||
0xc5,0x22,0x29,0x0c,0x74,0x25,0x02,0x03,0x01,0x00,0x01,0xa3,0x82,0x01,0xb3,
|
||||
0x30,0x82,0x01,0xaf,0x30,0x1f,0x06,0x03,0x55,0x1d,0x23,0x04,0x18,0x30,0x16,
|
||||
0x80,0x14,0x6b,0x69,0x3d,0x6a,0x18,0x42,0x4a,0xdd,0x8f,0x02,0x65,0x39,0xfd,
|
||||
0x35,0x24,0x86,0x78,0x91,0x16,0x30,0x30,0x0e,0x06,0x03,0x55,0x1d,0x0f,0x01,
|
||||
0x01,0xff,0x04,0x04,0x03,0x02,0x05,0xa0,0x30,0x1d,0x06,0x03,0x55,0x1d,0x25,
|
||||
0x04,0x16,0x30,0x14,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x03,0x01,0x06,
|
||||
0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x30,0x23,0x06,0x03,0x55,0x1d,
|
||||
0x11,0x04,0x1c,0x30,0x1a,0x82,0x0c,0x2a,0x2e,0x77,0x69,0x6e,0x65,0x68,0x71,
|
||||
0x2e,0x6f,0x72,0x67,0x82,0x0a,0x77,0x69,0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,
|
||||
0x67,0x30,0x43,0x06,0x03,0x55,0x1d,0x1f,0x04,0x3c,0x30,0x3a,0x30,0x38,0xa0,
|
||||
0x36,0xa0,0x34,0x86,0x32,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x72,0x61,0x70,
|
||||
0x69,0x64,0x73,0x73,0x6c,0x2d,0x63,0x72,0x6c,0x2e,0x67,0x65,0x6f,0x74,0x72,
|
||||
0x75,0x73,0x74,0x2e,0x63,0x6f,0x6d,0x2f,0x63,0x72,0x6c,0x73,0x2f,0x72,0x61,
|
||||
0x70,0x69,0x64,0x73,0x73,0x6c,0x2e,0x63,0x72,0x6c,0x30,0x1d,0x06,0x03,0x55,
|
||||
0x1d,0x0e,0x04,0x16,0x04,0x14,0xff,0x4c,0x0f,0x46,0xb8,0x3c,0x5b,0x72,0xe4,
|
||||
0x10,0x96,0xbb,0xa7,0xbc,0x91,0xa2,0x63,0xf6,0x81,0x0a,0x30,0x0c,0x06,0x03,
|
||||
0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x02,0x30,0x00,0x30,0x78,0x06,0x08,0x2b,
|
||||
0x06,0x01,0x05,0x05,0x07,0x01,0x01,0x04,0x6c,0x30,0x6a,0x30,0x2d,0x06,0x08,
|
||||
0x2b,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x86,0x21,0x68,0x74,0x74,0x70,0x3a,
|
||||
0x2f,0x2f,0x72,0x61,0x70,0x69,0x64,0x73,0x73,0x6c,0x2d,0x6f,0x63,0x73,0x70,
|
||||
0x2e,0x67,0x65,0x6f,0x74,0x72,0x75,0x73,0x74,0x2e,0x63,0x6f,0x6d,0x30,0x39,
|
||||
0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x30,0x02,0x86,0x2d,0x68,0x74,0x74,
|
||||
0x70,0x3a,0x2f,0x2f,0x72,0x61,0x70,0x69,0x64,0x73,0x73,0x6c,0x2d,0x61,0x69,
|
||||
0x61,0x2e,0x67,0x65,0x6f,0x74,0x72,0x75,0x73,0x74,0x2e,0x63,0x6f,0x6d,0x2f,
|
||||
0x72,0x61,0x70,0x69,0x64,0x73,0x73,0x6c,0x2e,0x63,0x72,0x74,0x30,0x4c,0x06,
|
||||
0x03,0x55,0x1d,0x20,0x04,0x45,0x30,0x43,0x30,0x41,0x06,0x0a,0x60,0x86,0x48,
|
||||
0x01,0x86,0xf8,0x45,0x01,0x07,0x36,0x30,0x33,0x30,0x31,0x06,0x08,0x2b,0x06,
|
||||
0x01,0x05,0x05,0x07,0x02,0x01,0x16,0x25,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,
|
||||
0x77,0x77,0x77,0x2e,0x67,0x65,0x6f,0x74,0x72,0x75,0x73,0x74,0x2e,0x63,0x6f,
|
||||
0x6d,0x2f,0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x73,0x2f,0x63,0x70,0x73,
|
||||
0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,
|
||||
0x03,0x82,0x01,0x01,0x00,0x1b,0xa8,0x34,0xc1,0xb7,0xf3,0xbe,0xb6,0xed,0x12,
|
||||
0x85,0x58,0xe1,0x69,0x35,0x0c,0xb8,0x7e,0x38,0x11,0xb3,0xd2,0xe2,0x2e,0x52,
|
||||
0xcf,0xa6,0x39,0xe1,0x25,0x73,0xf0,0x1d,0xc9,0x54,0xa1,0xc2,0x50,0x19,0xea,
|
||||
0x68,0xeb,0x1a,0x21,0xdb,0x86,0x14,0x55,0x73,0x02,0x28,0x56,0x14,0xf7,0xf1,
|
||||
0x48,0x43,0xfb,0xd7,0xbf,0xcf,0xbb,0x20,0xc4,0x1e,0x4e,0x9a,0x7c,0xf1,0xe8,
|
||||
0x28,0x76,0xce,0xf9,0xb3,0xf0,0x6f,0x93,0x70,0x51,0xcd,0xed,0x28,0x1b,0xdd,
|
||||
0x66,0x38,0x40,0x5e,0x0b,0x13,0xaf,0x21,0xff,0x23,0xf1,0x5b,0xcd,0x32,0x43,
|
||||
0x00,0x87,0x3d,0x10,0xc6,0x6e,0xe5,0x67,0xdc,0x9f,0x44,0x12,0x94,0xb4,0x76,
|
||||
0xbd,0xd9,0x4c,0x53,0x12,0x1c,0x2e,0x2c,0x09,0x66,0x41,0x83,0x6c,0xee,0x68,
|
||||
0x98,0x38,0xd2,0xc8,0x32,0xa3,0x42,0xcf,0x1c,0xfd,0x60,0x6c,0x5d,0x4b,0x4b,
|
||||
0x6c,0xb8,0xf3,0x7e,0xc8,0x93,0x0a,0x68,0x66,0x14,0x3b,0x39,0x73,0x82,0xfe,
|
||||
0x86,0x3c,0x3d,0xb3,0xb5,0x42,0xec,0x4c,0xc6,0xe6,0xdd,0x7e,0xd7,0xb4,0x5d,
|
||||
0xeb,0x6d,0x8c,0x9e,0x29,0x95,0x99,0xb6,0x95,0x5b,0xc0,0xdd,0x46,0xdf,0xdc,
|
||||
0xf2,0x1c,0x3d,0x80,0xeb,0x14,0x3d,0xd9,0x4a,0xb4,0x6f,0x3e,0x79,0xca,0x7f,
|
||||
0xbc,0x27,0x47,0x90,0x86,0x55,0xfa,0x27,0xf5,0x35,0x3d,0x1d,0xc4,0xa8,0x55,
|
||||
0x31,0x8f,0x3a,0x76,0x8d,0x98,0x50,0xa3,0x11,0x91,0x1c,0xb0,0xa8,0x06,0xf9,
|
||||
0x22,0xb1,0xca,0x20,0x49,0xaa,0xe1,0x4d,0x41,0xf1,0x21,0xcc,0x25,0x45,0x33,
|
||||
0x4f,0x2f,0x3a,0x48,0x70,0xbb };
|
||||
/* Battle.Net's cert */
|
||||
static const BYTE battlenet[] = {
|
||||
0x30,0x82,0x03,0xd8,0x30,0x82,0x02,0xc0,0xa0,0x03,0x02,0x01,0x02,0x02,0x10,
|
||||
|
@ -3673,6 +3764,17 @@ static SYSTEMTIME oct2007 = { 2007, 10, 1, 1, 0, 0, 0, 0 };
|
|||
static SYSTEMTIME oct2009 = { 2009, 10, 3, 28, 0, 0, 0, 0 };
|
||||
/* Wednesday, Oct 28, 2010 */
|
||||
static SYSTEMTIME oct2010 = { 2010, 10, 3, 28, 0, 0, 0, 0 };
|
||||
/* Friday, June 6, 2013 */
|
||||
static SYSTEMTIME jun2013 = { 2013, 6, 5, 6, 0, 0, 0, 0 };
|
||||
|
||||
#define test_name_blob(a,b) _test_name_blob(__LINE__,a,b)
|
||||
static void _test_name_blob(unsigned line, CERT_NAME_BLOB *blob, const char *exdata)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
CertNameToStrA(CRYPT_ASN_ENCODING, blob, CERT_SIMPLE_NAME_STR, buf, sizeof(buf));
|
||||
ok_(__FILE__,line)(!strcmp(buf, exdata), "got string %s, expected %s\n", buf, exdata);
|
||||
}
|
||||
|
||||
static void testGetCertChain(void)
|
||||
{
|
||||
|
@ -3680,6 +3782,8 @@ static void testGetCertChain(void)
|
|||
PCCERT_CONTEXT cert;
|
||||
CERT_CHAIN_PARA para = { 0 };
|
||||
PCCERT_CHAIN_CONTEXT chain;
|
||||
const CERT_SIMPLE_CHAIN *simple_chain;
|
||||
const CERT_CHAIN_ELEMENT *chain_elem;
|
||||
FILETIME fileTime;
|
||||
DWORD i;
|
||||
HCERTSTORE store;
|
||||
|
@ -3874,6 +3978,68 @@ static void testGetCertChain(void)
|
|||
0);
|
||||
pCertFreeCertificateChain(chain);
|
||||
}
|
||||
|
||||
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
|
||||
ok(store != NULL, "CertOpenStore failed: %u\n", GetLastError());
|
||||
|
||||
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, winehq_org, sizeof(winehq_org),
|
||||
CERT_STORE_ADD_ALWAYS, &cert);
|
||||
ok(ret, "CertAddEncodedCertificateToStore failed: %u\n", GetLastError());
|
||||
|
||||
oids[0] = oid_server_auth;
|
||||
memset(¶, 0, sizeof(para));
|
||||
para.cbSize = sizeof(para);
|
||||
para.RequestedUsage.Usage.cUsageIdentifier = 1;
|
||||
para.RequestedUsage.Usage.rgpszUsageIdentifier = oids;
|
||||
SystemTimeToFileTime(&jun2013, &fileTime);
|
||||
|
||||
/* Pass store that does not contain all certs in chain. */
|
||||
ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, 0, NULL, &chain);
|
||||
ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError());
|
||||
|
||||
if(chain->TrustStatus.dwErrorStatus == CERT_TRUST_IS_PARTIAL_CHAIN) { /* win2k */
|
||||
todo_wine win_skip("winehq cert reported as partial chain, skipping its tests\n");
|
||||
pCertFreeCertificateChain(chain);
|
||||
CertCloseStore(store, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(!chain->TrustStatus.dwErrorStatus, "chain->TrustStatus.dwErrorStatus = %x\n", chain->TrustStatus.dwErrorStatus);
|
||||
ok(chain->TrustStatus.dwInfoStatus == CERT_TRUST_HAS_PREFERRED_ISSUER, "chain->TrustStatus.dwInfoStatus = %x\n",
|
||||
chain->TrustStatus.dwInfoStatus);
|
||||
|
||||
ok(chain->cChain == 1, "chain->cChain = %d\n", chain->cChain);
|
||||
ok(!chain->cLowerQualityChainContext, "chain->cLowerQualityChainContext = %x\n", chain->cLowerQualityChainContext);
|
||||
ok(!chain->rgpLowerQualityChainContext, "chain->rgpLowerQualityChainContext = %p\n", chain->rgpLowerQualityChainContext);
|
||||
|
||||
simple_chain = *chain->rgpChain;
|
||||
ok(simple_chain->cbSize == sizeof(*simple_chain), "simple_chain->cbSize = %u\n", simple_chain->cbSize);
|
||||
ok(!simple_chain->TrustStatus.dwErrorStatus, "simple_chain->TrustStatus.dwErrorStatus = %x\n",
|
||||
simple_chain->TrustStatus.dwErrorStatus);
|
||||
ok(simple_chain->TrustStatus.dwInfoStatus == CERT_TRUST_HAS_PREFERRED_ISSUER,
|
||||
"simple_chain->TrustStatus.dwInfoStatus = %x\n", simple_chain->TrustStatus.dwInfoStatus);
|
||||
ok(simple_chain->cElement == 3, "simple_chain->cElement = %u\n", simple_chain->cElement);
|
||||
|
||||
for(i=0; i < simple_chain->cElement; i++) {
|
||||
chain_elem = simple_chain->rgpElement[i];
|
||||
ok(chain_elem->cbSize == sizeof(*chain_elem), "chain_elem->cbSize = %u\n", chain_elem->cbSize);
|
||||
|
||||
ok(!chain_elem->TrustStatus.dwErrorStatus, "chain_elem->TrustStatus.dwErrorStatus = %x\n",
|
||||
chain_elem->TrustStatus.dwErrorStatus);
|
||||
trace("info[%u] = %x\n", i, chain_elem->TrustStatus.dwInfoStatus);
|
||||
ok(chain_elem->pCertContext->dwCertEncodingType == CRYPT_ASN_ENCODING,
|
||||
"chain_elem->pCertContext->dwCertEncodingType = %x\n",
|
||||
chain_elem->pCertContext->dwCertEncodingType);
|
||||
}
|
||||
|
||||
ok(simple_chain->rgpElement[0]->pCertContext == cert, "simple_chain->rgpElement[0]->pCertContext != cert\n");
|
||||
test_name_blob(&simple_chain->rgpElement[1]->pCertContext->pCertInfo->Issuer, "US, GeoTrust Inc., GeoTrust Global CA");
|
||||
test_name_blob(&simple_chain->rgpElement[1]->pCertContext->pCertInfo->Subject, "US, \"GeoTrust, Inc.\", RapidSSL CA");
|
||||
test_name_blob(&simple_chain->rgpElement[2]->pCertContext->pCertInfo->Issuer, "US, GeoTrust Inc., GeoTrust Global CA");
|
||||
test_name_blob(&simple_chain->rgpElement[2]->pCertContext->pCertInfo->Subject, "US, GeoTrust Inc., GeoTrust Global CA");
|
||||
|
||||
pCertFreeCertificateChain(chain);
|
||||
CertCloseStore(store, 0);
|
||||
}
|
||||
|
||||
static void test_CERT_CHAIN_PARA_cbSize(void)
|
||||
|
|
Loading…
Reference in a new issue