Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
70ff9620
Commit
70ff9620
authored
Jul 20, 2014
by
Bruno Jesus
Committed by
Alexandre Julliard
Jul 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32/tests: Add more tests related to certificates.
Thanks to Juan Lang for help.
parent
7865b1a2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
2 deletions
+61
-2
cert.c
dlls/crypt32/tests/cert.c
+61
-2
No files found.
dlls/crypt32/tests/cert.c
View file @
70ff9620
...
...
@@ -1564,8 +1564,12 @@ static const BYTE chain7_1[] = {
static
void
testGetIssuerCert
(
void
)
{
BOOL
ret
;
PCCERT_CONTEXT
parent
,
child
,
cert1
,
cert2
;
DWORD
flags
=
0xffffffff
;
PCCERT_CONTEXT
parent
,
child
,
cert1
,
cert2
,
cert3
;
DWORD
flags
=
0xffffffff
,
size
;
CERT_NAME_BLOB
certsubject
;
BYTE
*
certencoded
;
WCHAR
rootW
[]
=
{
'R'
,
'O'
,
'O'
,
'T'
,
'\0'
},
certname
[]
=
{
'C'
,
'N'
,
'='
,
'd'
,
'u'
,
'm'
,
'm'
,
'y'
,
','
,
' '
,
'T'
,
'='
,
'T'
,
'e'
,
's'
,
't'
,
'\0'
};
HCERTSTORE
store
=
CertOpenStore
(
CERT_STORE_PROV_MEMORY
,
0
,
0
,
CERT_STORE_CREATE_NEW_FLAG
,
NULL
);
...
...
@@ -1640,6 +1644,7 @@ static void testGetIssuerCert(void)
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08x
\n
"
,
GetLastError
());
parent
=
CertGetIssuerCertificateFromStore
(
store
,
child
,
NULL
,
&
flags
);
ok
(
parent
==
NULL
,
"Expected no issuer
\n
"
);
ok
(
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
"Expected CRYPT_E_NOT_FOUND, got %08X
\n
"
,
GetLastError
());
/* Adding an issuer allows one (and only one) issuer to be found */
ret
=
CertAddEncodedCertificateToStore
(
store
,
X509_ASN_ENCODING
,
chain10_1
,
sizeof
(
chain10_1
),
CERT_STORE_ADD_ALWAYS
,
&
cert1
);
...
...
@@ -1648,6 +1653,7 @@ static void testGetIssuerCert(void)
ok
(
parent
==
cert1
,
"Expected cert1 to be the issuer
\n
"
);
parent
=
CertGetIssuerCertificateFromStore
(
store
,
child
,
parent
,
&
flags
);
ok
(
parent
==
NULL
,
"Expected only one issuer
\n
"
);
ok
(
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
"Expected CRYPT_E_NOT_FOUND, got %08X
\n
"
,
GetLastError
());
/* Adding a second issuer allows two issuers to be found - and the second
* issuer is found before the first, implying certs are added to the head
* of a list.
...
...
@@ -1661,6 +1667,7 @@ static void testGetIssuerCert(void)
ok
(
parent
==
cert1
,
"Expected cert1 to be the second issuer
\n
"
);
parent
=
CertGetIssuerCertificateFromStore
(
store
,
child
,
parent
,
&
flags
);
ok
(
parent
==
NULL
,
"Expected no more than two issuers
\n
"
);
ok
(
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
"Expected CRYPT_E_NOT_FOUND, got %08X
\n
"
,
GetLastError
());
CertFreeCertificateContext
(
child
);
CertFreeCertificateContext
(
cert1
);
CertFreeCertificateContext
(
cert2
);
...
...
@@ -1677,6 +1684,7 @@ static void testGetIssuerCert(void)
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08x
\n
"
,
GetLastError
());
parent
=
CertGetIssuerCertificateFromStore
(
store
,
child
,
NULL
,
&
flags
);
ok
(
parent
==
NULL
,
"Expected no issuer
\n
"
);
ok
(
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
"Expected CRYPT_E_NOT_FOUND, got %08X
\n
"
,
GetLastError
());
/* Adding an issuer allows one (and only one) issuer to be found */
ret
=
CertAddEncodedCertificateToStore
(
store
,
X509_ASN_ENCODING
,
chain10_0
,
sizeof
(
chain10_0
),
CERT_STORE_ADD_ALWAYS
,
&
cert1
);
...
...
@@ -1685,6 +1693,7 @@ static void testGetIssuerCert(void)
ok
(
parent
==
cert1
,
"Expected cert1 to be the issuer
\n
"
);
parent
=
CertGetIssuerCertificateFromStore
(
store
,
child
,
parent
,
&
flags
);
ok
(
parent
==
NULL
,
"Expected only one issuer
\n
"
);
ok
(
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
"Expected CRYPT_E_NOT_FOUND, got %08X
\n
"
,
GetLastError
());
/* Adding a second issuer allows two issuers to be found - and the second
* issuer is found before the first, implying certs are added to the head
* of a list.
...
...
@@ -1698,10 +1707,60 @@ static void testGetIssuerCert(void)
ok
(
parent
==
cert1
,
"Expected cert1 to be the second issuer
\n
"
);
parent
=
CertGetIssuerCertificateFromStore
(
store
,
child
,
parent
,
&
flags
);
ok
(
parent
==
NULL
,
"Expected no more than two issuers
\n
"
);
ok
(
GetLastError
()
==
CRYPT_E_NOT_FOUND
,
"Expected CRYPT_E_NOT_FOUND, got %08X
\n
"
,
GetLastError
());
/* Self-sign a certificate, add to the store and test getting the issuer */
size
=
0
;
todo_wine
ok
(
CertStrToNameW
(
X509_ASN_ENCODING
,
certname
,
CERT_X500_NAME_STR
,
NULL
,
NULL
,
&
size
,
NULL
),
"CertStrToName should have worked
\n
"
);
certencoded
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
todo_wine
ok
(
CertStrToNameW
(
X509_ASN_ENCODING
,
certname
,
CERT_X500_NAME_STR
,
NULL
,
certencoded
,
&
size
,
NULL
),
"CertStrToName should have worked
\n
"
);
certsubject
.
pbData
=
certencoded
;
certsubject
.
cbData
=
size
;
cert3
=
CertCreateSelfSignCertificate
(
0
,
&
certsubject
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
/* wine fails to create the certificate, this makes it crash later.
* Remove IF when wine is fixed, all windows versions must work */
if
(
cert3
==
NULL
)
{
todo_wine
ok
(
0
,
"Must work on windows
\n
"
);
goto
skiptest
;
}
ok
(
cert3
!=
NULL
,
"CertCreateSelfSignCertificate should have worked
\n
"
);
ret
=
CertAddCertificateContextToStore
(
store
,
cert3
,
CERT_STORE_ADD_REPLACE_EXISTING
,
0
);
ok
(
ret
,
"CertAddEncodedCertificateToStore failed: %08x
\n
"
,
GetLastError
());
CertFreeCertificateContext
(
cert3
);
cert3
=
CertEnumCertificatesInStore
(
store
,
NULL
);
ok
(
cert3
!=
NULL
,
"CertEnumCertificatesInStore should have worked
\n
"
);
SetLastError
(
0xdeadbeef
);
flags
=
0
;
parent
=
CertGetIssuerCertificateFromStore
(
store
,
cert3
,
NULL
,
&
flags
);
ok
(
!
parent
,
"Expected NULL
\n
"
);
ok
(
GetLastError
()
==
CRYPT_E_SELF_SIGNED
,
"Expected CRYPT_E_SELF_SIGNED, got %08X
\n
"
,
GetLastError
());
skiptest:
CertFreeCertificateContext
(
child
);
CertFreeCertificateContext
(
cert1
);
CertFreeCertificateContext
(
cert2
);
CertCloseStore
(
store
,
0
);
HeapFree
(
GetProcessHeap
(),
0
,
certencoded
);
/* Test root storage self-signed certificate */
store
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM
,
0
,
0
,
CERT_SYSTEM_STORE_CURRENT_USER
,
rootW
);
ok
(
store
!=
NULL
,
"CertOpenStore failed: %08x
\n
"
,
GetLastError
());
flags
=
0
;
cert1
=
CertEnumCertificatesInStore
(
store
,
NULL
);
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
);
}
static
void
testCryptHashCert
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment