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
ab9a53f6
Commit
ab9a53f6
authored
Oct 24, 2008
by
Juan Lang
Committed by
Alexandre Julliard
Oct 27, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cryptui: Choose appropriate destination store for a cert.
parent
4b66952b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
9 deletions
+74
-9
main.c
dlls/cryptui/main.c
+71
-3
cryptui.c
dlls/cryptui/tests/cryptui.c
+3
-6
No files found.
dlls/cryptui/main.c
View file @
ab9a53f6
...
...
@@ -139,10 +139,79 @@ static PCCERT_CONTEXT make_cert_from_file(LPCWSTR fileName)
return
cert
;
}
/* Decodes a cert's basic constraints extension (either szOID_BASIC_CONSTRAINTS
* or szOID_BASIC_CONSTRAINTS2, whichever is present) to determine if it
* should be a CA. If neither extension is present, returns
* defaultIfNotSpecified.
*/
static
BOOL
is_ca_cert
(
PCCERT_CONTEXT
cert
,
BOOL
defaultIfNotSpecified
)
{
BOOL
isCA
=
defaultIfNotSpecified
;
PCERT_EXTENSION
ext
=
CertFindExtension
(
szOID_BASIC_CONSTRAINTS
,
cert
->
pCertInfo
->
cExtension
,
cert
->
pCertInfo
->
rgExtension
);
if
(
ext
)
{
CERT_BASIC_CONSTRAINTS_INFO
*
info
;
DWORD
size
=
0
;
if
(
CryptDecodeObjectEx
(
X509_ASN_ENCODING
,
szOID_BASIC_CONSTRAINTS
,
ext
->
Value
.
pbData
,
ext
->
Value
.
cbData
,
CRYPT_DECODE_ALLOC_FLAG
,
NULL
,
(
LPBYTE
)
&
info
,
&
size
))
{
if
(
info
->
SubjectType
.
cbData
==
1
)
isCA
=
info
->
SubjectType
.
pbData
[
0
]
&
CERT_CA_SUBJECT_FLAG
;
LocalFree
(
info
);
}
}
else
{
ext
=
CertFindExtension
(
szOID_BASIC_CONSTRAINTS2
,
cert
->
pCertInfo
->
cExtension
,
cert
->
pCertInfo
->
rgExtension
);
if
(
ext
)
{
CERT_BASIC_CONSTRAINTS2_INFO
info
;
DWORD
size
=
sizeof
(
CERT_BASIC_CONSTRAINTS2_INFO
);
if
(
CryptDecodeObjectEx
(
X509_ASN_ENCODING
,
szOID_BASIC_CONSTRAINTS2
,
ext
->
Value
.
pbData
,
ext
->
Value
.
cbData
,
0
,
NULL
,
&
info
,
&
size
))
isCA
=
info
.
fCA
;
}
}
return
isCA
;
}
static
inline
BOOL
is_cert_self_signed
(
PCCERT_CONTEXT
cert
)
{
return
CertCompareCertificateName
(
cert
->
dwCertEncodingType
,
&
cert
->
pCertInfo
->
Subject
,
&
cert
->
pCertInfo
->
Issuer
);
}
static
HCERTSTORE
choose_store_for_cert
(
PCCERT_CONTEXT
cert
)
{
static
const
WCHAR
Root
[]
=
{
'R'
,
'o'
,
'o'
,
't'
,
0
};
static
const
WCHAR
AddressBook
[]
=
{
'A'
,
'd'
,
'd'
,
'r'
,
'e'
,
's'
,
's'
,
'B'
,
'o'
,
'o'
,
'k'
,
0
};
static
const
WCHAR
CA
[]
=
{
'C'
,
'A'
,
0
};
LPCWSTR
storeName
;
if
(
is_ca_cert
(
cert
,
TRUE
))
{
if
(
is_cert_self_signed
(
cert
))
storeName
=
Root
;
else
storeName
=
CA
;
}
else
storeName
=
AddressBook
;
return
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_W
,
0
,
0
,
CERT_SYSTEM_STORE_CURRENT_USER
,
storeName
);
}
BOOL
WINAPI
CryptUIWizImport
(
DWORD
dwFlags
,
HWND
hwndParent
,
LPCWSTR
pwszWizardTitle
,
PCCRYPTUI_WIZ_IMPORT_SRC_INFO
pImportSrc
,
HCERTSTORE
hDestCertStore
)
{
static
const
WCHAR
Root
[]
=
{
'R'
,
'o'
,
'o'
,
't'
,
0
};
BOOL
ret
;
HCERTSTORE
store
;
const
CERT_CONTEXT
*
cert
;
...
...
@@ -187,8 +256,7 @@ BOOL WINAPI CryptUIWizImport(DWORD dwFlags, HWND hwndParent, LPCWSTR pwszWizardT
if
(
hDestCertStore
)
store
=
hDestCertStore
;
else
{
FIXME
(
"certificate store should be determined dynamically, picking Root store
\n
"
);
if
(
!
(
store
=
CertOpenStore
(
CERT_STORE_PROV_SYSTEM_W
,
0
,
0
,
CERT_SYSTEM_STORE_CURRENT_USER
,
Root
)))
if
(
!
(
store
=
choose_store_for_cert
(
cert
)))
{
WARN
(
"unable to open certificate store
\n
"
);
CertFreeCertificateContext
(
cert
);
...
...
dlls/cryptui/tests/cryptui.c
View file @
ab9a53f6
...
...
@@ -396,7 +396,6 @@ static void test_crypt_ui_wiz_import(void)
info
.
u
.
pCertContext
=
CertCreateCertificateContext
(
X509_ASN_ENCODING
,
iTunesCert3
,
sizeof
(
iTunesCert3
));
ret
=
pCryptUIWizImport
(
CRYPTUI_WIZ_NO_UI
,
0
,
NULL
,
&
info
,
NULL
);
todo_wine
ok
(
ret
,
"CryptUIWizImport failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
@@ -408,7 +407,7 @@ static void test_crypt_ui_wiz_import(void)
if
(
addressBook
)
{
find_and_delete_cert_in_store
(
addressBook
,
"AddressBook"
,
info
.
u
.
pCertContext
,
"iTunesCert3"
,
TRU
E
);
info
.
u
.
pCertContext
,
"iTunesCert3"
,
FALS
E
);
CertCloseStore
(
addressBook
,
0
);
}
}
...
...
@@ -446,7 +445,6 @@ static void test_crypt_ui_wiz_import(void)
info
.
u
.
pCertContext
=
CertCreateCertificateContext
(
X509_ASN_ENCODING
,
iTunesCert1
,
sizeof
(
iTunesCert1
));
ret
=
pCryptUIWizImport
(
CRYPTUI_WIZ_NO_UI
,
0
,
NULL
,
&
info
,
NULL
);
todo_wine
ok
(
ret
,
"CryptUIWizImport failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
@@ -458,7 +456,7 @@ static void test_crypt_ui_wiz_import(void)
if
(
addressBook
)
{
find_and_delete_cert_in_store
(
addressBook
,
"AddressBook"
,
info
.
u
.
pCertContext
,
"iTunesCert1"
,
TRU
E
);
info
.
u
.
pCertContext
,
"iTunesCert1"
,
FALS
E
);
CertCloseStore
(
addressBook
,
0
);
}
}
...
...
@@ -467,7 +465,6 @@ static void test_crypt_ui_wiz_import(void)
info
.
u
.
pCertContext
=
CertCreateCertificateContext
(
X509_ASN_ENCODING
,
iTunesCert2
,
sizeof
(
iTunesCert2
));
ret
=
pCryptUIWizImport
(
CRYPTUI_WIZ_NO_UI
,
0
,
NULL
,
&
info
,
NULL
);
todo_wine
ok
(
ret
,
"CryptUIWizImport failed: %08x
\n
"
,
GetLastError
());
if
(
ret
)
{
...
...
@@ -478,7 +475,7 @@ static void test_crypt_ui_wiz_import(void)
if
(
ca
)
{
find_and_delete_cert_in_store
(
ca
,
"CA"
,
info
.
u
.
pCertContext
,
"iTunesCert2"
,
TRU
E
);
info
.
u
.
pCertContext
,
"iTunesCert2"
,
FALS
E
);
CertCloseStore
(
ca
,
0
);
}
}
...
...
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