Commit a7c236a0 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

cryptnet: Add tests for getting the certificate issuer URL from a cert's…

cryptnet: Add tests for getting the certificate issuer URL from a cert's authority info access extension.
parent cb035848
......@@ -60,6 +60,29 @@ static const BYTE certWithCRLDistPoint[] = {
0x25,0x06,0x03,0x55,0x1d,0x1f,0x01,0x01,0xff,0x04,0x1b,0x30,0x19,0x30,0x17,
0xa0,0x15,0xa0,0x13,0x86,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,
0x6e,0x65,0x68,0x71,0x2e,0x6f,0x72,0x67, };
static const BYTE certWithAIAWithCAIssuers[] = {
0x30,0x82,0x01,0x3c,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,0x30,0x0b,0x06,
0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x30,0x14,0x31,0x12,0x30,
0x10,0x06,0x03,0x55,0x04,0x03,0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,
0x6e,0x67,0x30,0x1e,0x17,0x0d,0x30,0x39,0x31,0x30,0x32,0x38,0x30,0x30,0x30,
0x30,0x30,0x30,0x5a,0x17,0x0d,0x32,0x30,0x31,0x31,0x32,0x37,0x30,0x30,0x30,
0x30,0x30,0x30,0x5a,0x30,0x14,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x03,
0x13,0x09,0x4a,0x75,0x61,0x6e,0x20,0x4c,0x61,0x6e,0x67,0x30,0x81,0xa5,0x30,
0x0b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x01,0x03,0x81,0x95,
0x00,0x06,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x52,0x53,0x41,0x31,0x00,0x04,
0x00,0x00,0x01,0x00,0x01,0x00,0x2f,0xb2,0x8c,0xff,0x6c,0xf1,0xb1,0x61,0x9c,
0x3a,0x8f,0x5e,0x35,0x2f,0x1f,0xd5,0xcf,0x2a,0xf6,0x9e,0x37,0xe8,0x89,0xa2,
0xb1,0x1c,0xc0,0x1c,0xb6,0x72,0x45,0x97,0xe5,0x88,0x3d,0xfe,0xa6,0x27,0xea,
0xd6,0x07,0x0f,0xcd,0xba,0x49,0x06,0x16,0xdb,0xad,0x06,0x76,0x39,0x4c,0x15,
0xdf,0xe2,0x07,0xc5,0x99,0x1b,0x98,0x4b,0xc3,0x8e,0x89,0x12,0x95,0x9e,0x3b,
0xb9,0x59,0xfe,0x91,0x33,0xc1,0x1f,0xce,0x8f,0xab,0x93,0x25,0x01,0x3e,0xde,
0xf1,0x58,0x3b,0xe7,0x7a,0x03,0x14,0x07,0x09,0x0a,0x21,0x2d,0x12,0x11,0x08,
0x78,0x07,0x9e,0x34,0xc3,0xc5,0xde,0xb2,0xd8,0xd7,0x86,0x0d,0x0d,0xcd,0x81,
0xa4,0x2d,0x7c,0x82,0x50,0xca,0x2a,0xc2,0x99,0xe5,0xf3,0xca,0x7e,0xad,0xa3,
0x31,0x30,0x2f,0x30,0x2d,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x01,0x01,
0x04,0x21,0x30,0x1f,0x30,0x1d,0x06,0x08,0x2b,0x06,0x01,0x05,0x05,0x07,0x30,
0x02,0x86,0x11,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,0x65,0x68,
0x71,0x2e,0x6f,0x72,0x67 };
static void compareUrlArray(const CRYPT_URL_ARRAY *expected,
const CRYPT_URL_ARRAY *got)
......@@ -231,6 +254,46 @@ static void test_getObjectUrl(void)
"Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
CertFreeCertificateContext(cert);
}
cert = CertCreateCertificateContext(X509_ASN_ENCODING,
certWithAIAWithCAIssuers, sizeof(certWithAIAWithCAIssuers));
if (cert)
{
PCRYPT_URL_ARRAY urlArray;
/* This has an AIA extension with the CA Issuers set, so expect it
* to succeed:
*/
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER,
(void *)cert, 0, NULL, &urlArraySize, NULL, NULL, NULL);
todo_wine
ok(ret, "CryptGetObjectUrl failed: %08x\n", GetLastError());
if (ret)
{
urlArray = HeapAlloc(GetProcessHeap(), 0, urlArraySize);
if (urlArray)
{
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_ISSUER,
(void *)cert, CRYPT_GET_URL_FROM_EXTENSION, urlArray,
&urlArraySize, NULL, NULL, NULL);
ok(ret, "CryptGetObjectUrl failed: %08x\n", GetLastError());
if (ret)
{
LPWSTR pUrl = url;
CRYPT_URL_ARRAY expectedUrl = { 1, &pUrl };
compareUrlArray(&expectedUrl, urlArray);
}
HeapFree(GetProcessHeap(), 0, urlArray);
}
}
/* It doesn't have a CRL dist points extension, so this should fail */
SetLastError(0xdeadbeef);
ret = CryptGetObjectUrl(URL_OID_CERTIFICATE_CRL_DIST_POINT,
(void *)cert, 0, NULL, &urlArraySize, NULL, NULL, NULL);
ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND,
"expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError());
CertFreeCertificateContext(cert);
}
}
static void make_tmp_file(LPSTR path)
......
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