Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
224ac7d6
Commit
224ac7d6
authored
Jun 07, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2e2bd898
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
DesktopEditor/xmlsec/test/OpenSSL_gui_test/opensslwrapper.cpp
...topEditor/xmlsec/test/OpenSSL_gui_test/opensslwrapper.cpp
+70
-0
No files found.
DesktopEditor/xmlsec/test/OpenSSL_gui_test/opensslwrapper.cpp
View file @
224ac7d6
...
@@ -173,5 +173,75 @@ int COpenssl_library::LoadKey(std::wstring file, std::string password)
...
@@ -173,5 +173,75 @@ int COpenssl_library::LoadKey(std::wstring file, std::string password)
int
COpenssl_library
::
LoadCert
(
std
::
wstring
file
,
std
::
string
password
)
int
COpenssl_library
::
LoadCert
(
std
::
wstring
file
,
std
::
string
password
)
{
{
BYTE
*
pData
=
NULL
;
DWORD
dwDataLen
;
if
(
!
NSFile
::
CFileBinary
::
ReadAllBytes
(
file
,
&
pData
,
dwDataLen
))
return
OPEN_SSL_WARNING_ERR
;
X509
*
pCert
=
NULL
;
char
*
pPassword
=
(
password
.
empty
())
?
NULL
:
(
char
*
)
password
.
c_str
();
BIO
*
bio
=
BIO_new_mem_buf
((
void
*
)
pData
,
(
int
)
dwDataLen
);
if
(
PEM_read_bio_X509
(
bio
,
&
pCert
,
NULL
,
(
void
*
)
pPassword
))
{
X509_free
(
pCert
);
BIO_free
(
bio
);
return
OPEN_SSL_WARNING_OK
;
}
std
::
string
sError
=
GetOpenSslErrors
();
if
(
IsOpenSslPasswordError
(
sError
))
{
X509_free
(
pCert
);
BIO_free
(
bio
);
return
OPEN_SSL_WARNING_PASS
;
}
BIO_free
(
bio
);
bio
=
BIO_new_mem_buf
((
void
*
)
pData
,
(
int
)
dwDataLen
);
if
(
d2i_X509_bio
(
bio
,
&
pCert
))
{
X509_free
(
pCert
);
BIO_free
(
bio
);
return
OPEN_SSL_WARNING_OK
;
}
sError
=
GetOpenSslErrors
();
if
(
IsOpenSslPasswordError
(
sError
))
{
X509_free
(
pCert
);
BIO_free
(
bio
);
return
OPEN_SSL_WARNING_PASS
;
}
BIO_free
(
bio
);
bio
=
BIO_new_mem_buf
((
void
*
)
pData
,
(
int
)
dwDataLen
);
PKCS12
*
p12
=
d2i_PKCS12_bio
(
bio
,
NULL
);
if
(
p12
)
{
EVP_PKEY
*
pKey
=
NULL
;
STACK_OF
(
X509
)
*
pCa
=
NULL
;
if
(
PKCS12_parse
(
p12
,
pPassword
,
&
pKey
,
&
pCert
,
&
pCa
))
{
sk_X509_pop_free
(
pCa
,
X509_free
);
X509_free
(
pCert
);
EVP_PKEY_free
(
pKey
);
PKCS12_free
(
p12
);
BIO_free
(
bio
);
return
OPEN_SSL_WARNING_ALL_OK
;
}
sError
=
GetOpenSslErrors
();
if
(
IsOpenSslPasswordError
(
sError
))
{
PKCS12_free
(
p12
);
BIO_free
(
bio
);
return
OPEN_SSL_WARNING_PASS
;
}
PKCS12_free
(
p12
);
}
BIO_free
(
bio
);
return
OPEN_SSL_WARNING_ERR
;
return
OPEN_SSL_WARNING_ERR
;
}
}
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