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
dd815611
Commit
dd815611
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: Move cert creation to a helper function.
parent
caa64b4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
35 deletions
+41
-35
main.c
dlls/cryptui/main.c
+41
-35
No files found.
dlls/cryptui/main.c
View file @
dd815611
...
...
@@ -99,15 +99,52 @@ BOOL WINAPI CryptUIDlgViewCertificateW(PCCRYPTUI_VIEWCERTIFICATE_STRUCTW pCertVi
return
TRUE
;
}
static
PCCERT_CONTEXT
make_cert_from_file
(
LPCWSTR
fileName
)
{
HANDLE
file
;
DWORD
size
,
encoding
=
X509_ASN_ENCODING
|
PKCS_7_ASN_ENCODING
;
BYTE
*
buffer
;
PCCERT_CONTEXT
cert
;
file
=
CreateFileW
(
fileName
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
if
(
file
==
INVALID_HANDLE_VALUE
)
{
WARN
(
"can't open certificate file %s
\n
"
,
debugstr_w
(
fileName
));
return
NULL
;
}
if
((
size
=
GetFileSize
(
file
,
NULL
)))
{
if
((
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
{
DWORD
read
;
if
(
!
ReadFile
(
file
,
buffer
,
size
,
&
read
,
NULL
)
||
read
!=
size
)
{
WARN
(
"can't read certificate file %s
\n
"
,
debugstr_w
(
fileName
));
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
CloseHandle
(
file
);
return
NULL
;
}
}
}
else
{
WARN
(
"empty file %s
\n
"
,
debugstr_w
(
fileName
));
CloseHandle
(
file
);
return
NULL
;
}
CloseHandle
(
file
);
cert
=
CertCreateCertificateContext
(
encoding
,
buffer
,
size
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
cert
;
}
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
;
HANDLE
file
;
HCERTSTORE
store
;
BYTE
*
buffer
;
DWORD
size
,
encoding
=
X509_ASN_ENCODING
|
PKCS_7_ASN_ENCODING
;
const
CERT_CONTEXT
*
cert
;
TRACE
(
"(0x%08x, %p, %s, %p, %p)
\n
"
,
dwFlags
,
hwndParent
,
debugstr_w
(
pwszWizardTitle
),
...
...
@@ -129,38 +166,9 @@ BOOL WINAPI CryptUIWizImport(DWORD dwFlags, HWND hwndParent, LPCWSTR pwszWizardT
FIXME
(
"source type not implemented: %u
\n
"
,
pImportSrc
->
dwSubjectChoice
);
return
FALSE
;
}
file
=
CreateFileW
(
pImportSrc
->
pwszFileName
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
if
(
file
==
INVALID_HANDLE_VALUE
)
{
WARN
(
"can't open certificate file %s
\n
"
,
debugstr_w
(
pImportSrc
->
pwszFileName
));
return
FALSE
;
}
if
((
size
=
GetFileSize
(
file
,
NULL
)))
{
if
((
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
{
DWORD
read
;
if
(
!
ReadFile
(
file
,
buffer
,
size
,
&
read
,
NULL
)
||
read
!=
size
)
{
WARN
(
"can't read certificate file %s
\n
"
,
debugstr_w
(
pImportSrc
->
pwszFileName
));
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
CloseHandle
(
file
);
return
FALSE
;
}
}
}
else
{
WARN
(
"empty file %s
\n
"
,
debugstr_w
(
pImportSrc
->
pwszFileName
));
CloseHandle
(
file
);
return
FALSE
;
}
CloseHandle
(
file
);
if
(
!
(
cert
=
CertCreateCertificateContext
(
encoding
,
buffer
,
size
)))
if
(
!
(
cert
=
make_cert_from_file
(
pImportSrc
->
pwszFileName
)))
{
WARN
(
"unable to create certificate context
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
FALSE
;
}
if
(
hDestCertStore
)
store
=
hDestCertStore
;
...
...
@@ -171,7 +179,6 @@ BOOL WINAPI CryptUIWizImport(DWORD dwFlags, HWND hwndParent, LPCWSTR pwszWizardT
{
WARN
(
"unable to open certificate store
\n
"
);
CertFreeCertificateContext
(
cert
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
FALSE
;
}
}
...
...
@@ -179,6 +186,5 @@ BOOL WINAPI CryptUIWizImport(DWORD dwFlags, HWND hwndParent, LPCWSTR pwszWizardT
if
(
!
hDestCertStore
)
CertCloseStore
(
store
,
0
);
CertFreeCertificateContext
(
cert
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
ret
;
}
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