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
0d961d9c
Commit
0d961d9c
authored
Feb 01, 2009
by
Juan Lang
Committed by
Alexandre Julliard
Feb 09, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cryptui: Implement exporting to a PFX file.
parent
8cb97022
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
2 deletions
+91
-2
main.c
dlls/cryptui/main.c
+91
-2
No files found.
dlls/cryptui/main.c
View file @
0d961d9c
...
...
@@ -6413,6 +6413,96 @@ static BOOL save_serialized_store(HANDLE file, HCERTSTORE store)
CERT_STORE_SAVE_AS_STORE
,
CERT_STORE_SAVE_TO_FILE
,
file
,
0
);
}
static
BOOL
save_pfx
(
HANDLE
file
,
PCCRYPTUI_WIZ_EXPORT_INFO
pExportInfo
,
PCCRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO
pContextInfo
)
{
HCERTSTORE
store
=
CertOpenStore
(
CERT_STORE_PROV_MEMORY
,
X509_ASN_ENCODING
,
0
,
CERT_STORE_CREATE_NEW_FLAG
,
NULL
);
BOOL
ret
=
FALSE
;
if
(
store
)
{
CRYPT_DATA_BLOB
pfxBlob
=
{
0
,
NULL
};
if
(
pContextInfo
->
fExportChain
)
{
HCERTCHAINENGINE
engine
=
NULL
;
if
(
pExportInfo
->
cStores
)
{
CERT_CHAIN_ENGINE_CONFIG
config
;
memset
(
&
config
,
0
,
sizeof
(
config
));
config
.
cbSize
=
sizeof
(
config
);
config
.
cAdditionalStore
=
pExportInfo
->
cStores
;
config
.
rghAdditionalStore
=
pExportInfo
->
rghStores
;
ret
=
CertCreateCertificateChainEngine
(
&
config
,
&
engine
);
}
else
ret
=
TRUE
;
if
(
ret
)
{
CERT_CHAIN_PARA
chainPara
;
PCCERT_CHAIN_CONTEXT
chain
;
memset
(
&
chainPara
,
0
,
sizeof
(
chainPara
));
chainPara
.
cbSize
=
sizeof
(
chainPara
);
ret
=
CertGetCertificateChain
(
engine
,
pExportInfo
->
u
.
pCertContext
,
NULL
,
NULL
,
&
chainPara
,
0
,
NULL
,
&
chain
);
if
(
ret
)
{
DWORD
i
,
j
;
for
(
i
=
0
;
ret
&&
i
<
chain
->
cChain
;
i
++
)
for
(
j
=
0
;
ret
&&
j
<
chain
->
rgpChain
[
i
]
->
cElement
;
j
++
)
ret
=
CertAddCertificateContextToStore
(
store
,
chain
->
rgpChain
[
i
]
->
rgpElement
[
j
]
->
pCertContext
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
CertFreeCertificateChain
(
chain
);
}
}
if
(
engine
)
CertFreeCertificateChainEngine
(
engine
);
}
else
ret
=
CertAddCertificateContextToStore
(
store
,
pExportInfo
->
u
.
pCertContext
,
CERT_STORE_ADD_ALWAYS
,
NULL
);
if
(
ret
)
{
DWORD
exportFlags
=
REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY
|
EXPORT_PRIVATE_KEYS
;
ret
=
PFXExportCertStore
(
store
,
&
pfxBlob
,
pContextInfo
->
pwszPassword
,
exportFlags
);
if
(
ret
)
{
pfxBlob
.
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
pfxBlob
.
cbData
);
if
(
pfxBlob
.
pbData
)
{
ret
=
PFXExportCertStore
(
store
,
&
pfxBlob
,
pContextInfo
->
pwszPassword
,
exportFlags
);
if
(
ret
)
{
DWORD
bytesWritten
;
ret
=
WriteFile
(
file
,
pfxBlob
.
pbData
,
pfxBlob
.
cbData
,
&
bytesWritten
,
NULL
);
}
}
else
{
SetLastError
(
ERROR_OUTOFMEMORY
);
ret
=
FALSE
;
}
}
}
CertCloseStore
(
store
,
0
);
}
return
ret
;
}
static
BOOL
do_export
(
HANDLE
file
,
PCCRYPTUI_WIZ_EXPORT_INFO
pExportInfo
,
PCCRYPTUI_WIZ_EXPORT_CERTCONTEXT_INFO
pContextInfo
)
{
...
...
@@ -6458,8 +6548,7 @@ static BOOL do_export(HANDLE file, PCCRYPTUI_WIZ_EXPORT_INFO pExportInfo,
pContextInfo
->
fExportChain
);
break
;
case
CRYPTUI_WIZ_EXPORT_FORMAT_PFX
:
FIXME
(
"unimplemented for PFX
\n
"
);
ret
=
FALSE
;
ret
=
save_pfx
(
file
,
pExportInfo
,
pContextInfo
);
break
;
default:
SetLastError
(
E_FAIL
);
...
...
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