Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
661d8070
Commit
661d8070
authored
Mar 01, 2006
by
Juan Lang
Committed by
Alexandre Julliard
Mar 01, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Use CertFindCertificateInStore to simplify adding certificates.
parent
b84c9d41
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
50 deletions
+28
-50
store.c
dlls/crypt32/store.c
+28
-50
No files found.
dlls/crypt32/store.c
View file @
661d8070
...
...
@@ -373,74 +373,50 @@ static BOOL CRYPT_MemAddCert(PWINECRYPT_CERTSTORE store,
{
WINE_MEMSTORE
*
ms
=
(
WINE_MEMSTORE
*
)
store
;
BOOL
add
=
FALSE
,
ret
;
PCCERT_CONTEXT
existing
=
NULL
;
TRACE
(
"(%p, %p, %ld, %p)
\n
"
,
store
,
cert
,
dwAddDisposition
,
ppStoreContext
);
switch
(
dwAddDisposition
)
{
case
CERT_STORE_ADD_ALWAYS
:
add
=
TRUE
;
break
;
case
CERT_STORE_ADD_NEW
:
if
(
dwAddDisposition
!=
CERT_STORE_ADD_ALWAYS
)
{
BYTE
hashToAdd
[
20
]
,
hash
[
20
]
;
BYTE
hashToAdd
[
20
];
DWORD
size
=
sizeof
(
hashToAdd
);
ret
=
CRYPT_GetCertificateContextProperty
(
cert
,
CERT_HASH_PROP_ID
,
hashToAdd
,
&
size
);
if
(
ret
)
{
PWINE_CERT_LIST_ENTRY
cursor
;
CRYPT_HASH_BLOB
blob
=
{
sizeof
(
hashToAdd
),
hashToAdd
}
;
/* Add if no cert with the same hash is found. */
add
=
TRUE
;
EnterCriticalSection
(
&
ms
->
cs
);
LIST_FOR_EACH_ENTRY
(
cursor
,
&
ms
->
certs
,
WINE_CERT_LIST_ENTRY
,
entry
)
{
size
=
sizeof
(
hash
);
ret
=
CertGetCertificateContextProperty
(
&
cursor
->
cert
.
cert
,
CERT_HASH_PROP_ID
,
hash
,
&
size
);
if
(
ret
&&
!
memcmp
(
hashToAdd
,
hash
,
size
))
{
TRACE
(
"found matching certificate, not adding
\n
"
);
SetLastError
(
CRYPT_E_EXISTS
);
add
=
FALSE
;
break
;
}
}
LeaveCriticalSection
(
&
ms
->
cs
)
;
existing
=
CertFindCertificateInStore
(
store
,
cert
->
cert
.
dwCertEncodingType
,
0
,
CERT_FIND_SHA1_HASH
,
&
blob
,
NULL
);
}
}
switch
(
dwAddDisposition
)
{
case
CERT_STORE_ADD_ALWAYS
:
add
=
TRUE
;
break
;
case
CERT_STORE_ADD_NEW
:
{
if
(
existing
)
{
TRACE
(
"found matching certificate, not adding
\n
"
);
SetLastError
(
CRYPT_E_EXISTS
);
add
=
FALSE
;
}
else
add
=
TRUE
;
break
;
}
case
CERT_STORE_ADD_REPLACE_EXISTING
:
{
BYTE
hashToAdd
[
20
],
hash
[
20
];
DWORD
size
=
sizeof
(
hashToAdd
);
add
=
TRUE
;
ret
=
CRYPT_GetCertificateContextProperty
(
cert
,
CERT_HASH_PROP_ID
,
hashToAdd
,
&
size
);
if
(
ret
)
if
(
existing
)
{
PWINE_CERT_LIST_ENTRY
cursor
,
next
;
/* Look for existing cert to delete */
EnterCriticalSection
(
&
ms
->
cs
);
LIST_FOR_EACH_ENTRY_SAFE
(
cursor
,
next
,
&
ms
->
certs
,
WINE_CERT_LIST_ENTRY
,
entry
)
{
size
=
sizeof
(
hash
);
ret
=
CertGetCertificateContextProperty
(
&
cursor
->
cert
.
cert
,
CERT_HASH_PROP_ID
,
hash
,
&
size
);
if
(
ret
&&
!
memcmp
(
hashToAdd
,
hash
,
size
))
{
TRACE
(
"found matching certificate, replacing
\n
"
);
list_remove
(
&
cursor
->
entry
);
CertFreeCertificateContext
((
PCCERT_CONTEXT
)
cursor
);
break
;
}
}
LeaveCriticalSection
(
&
ms
->
cs
);
TRACE
(
"found matching certificate, replacing
\n
"
);
CertDeleteCertificateFromStore
(
existing
);
}
break
;
}
...
...
@@ -448,6 +424,8 @@ static BOOL CRYPT_MemAddCert(PWINECRYPT_CERTSTORE store,
FIXME
(
"Unimplemented add disposition %ld
\n
"
,
dwAddDisposition
);
add
=
FALSE
;
}
if
(
existing
)
CertFreeCertificateContext
(
existing
);
if
(
add
)
{
PWINE_CERT_LIST_ENTRY
entry
=
CryptMemAlloc
(
...
...
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