Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
f579eb35
Unverified
Commit
f579eb35
authored
May 07, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2536-insecure-samples
parent
8465cb08
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
18 deletions
+21
-18
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+12
-18
testw.cpp
testw.cpp
+7
-0
testw.h
testw.h
+2
-0
No files found.
SGXRegistrationServer.cpp
View file @
f579eb35
...
@@ -60,11 +60,13 @@ SGXRegistrationServer::SGXRegistrationServer(AbstractServerConnector &connector,
...
@@ -60,11 +60,13 @@ SGXRegistrationServer::SGXRegistrationServer(AbstractServerConnector &connector,
Json
::
Value
signCertificateImpl
(
const
string
&
_csr
,
bool
_autoSign
=
false
)
{
Json
::
Value
signCertificateImpl
(
const
string
&
_csr
,
bool
_autoSign
=
false
)
{
Json
::
Value
result
;
INIT_RESULT
(
result
)
result
[
"status"
]
=
0
;
result
[
"errorMessage"
]
=
""
;
result
[
"result"
]
=
false
;
try
{
try
{
spdlog
::
info
(
"enter signCertificateImpl"
);
spdlog
::
info
(
__FUNCTION__
);
string
status
=
"1"
;
string
status
=
"1"
;
string
hash
=
cryptlite
::
sha256
::
hash_hex
(
_csr
);
string
hash
=
cryptlite
::
sha256
::
hash_hex
(
_csr
);
...
@@ -102,12 +104,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
...
@@ -102,12 +104,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
string
db_key
=
"CSR:HASH:"
+
hash
+
"STATUS:"
;
string
db_key
=
"CSR:HASH:"
+
hash
+
"STATUS:"
;
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
db_key
,
status
);
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
db_key
,
status
);
}
catch
(
SGXException
&
_e
)
{
}
HANDLE_SGX_EXCEPTION
(
result
)
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
result
[
"result"
]
=
false
;
}
return
result
;
return
result
;
}
}
...
@@ -154,24 +151,21 @@ Json::Value GetSertificateImpl(const string &hash) {
...
@@ -154,24 +151,21 @@ Json::Value GetSertificateImpl(const string &hash) {
result
[
"status"
]
=
status
;
result
[
"status"
]
=
status
;
result
[
"cert"
]
=
cert
;
result
[
"cert"
]
=
cert
;
}
catch
(
SGXException
&
_e
)
{
}
HANDLE_SGX_EXCEPTION
(
result
)
cerr
<<
" err str "
<<
_e
.
errString
<<
endl
;
result
[
"status"
]
=
_e
.
status
;
result
[
"errorMessage"
]
=
_e
.
errString
;
}
return
result
;
return
result
;
}
}
Json
::
Value
SGXRegistrationServer
::
SignCertificate
(
const
string
&
csr
)
{
Json
::
Value
SGXRegistrationServer
::
SignCertificate
(
const
string
&
csr
)
{
spdlog
::
info
(
"Enter signCertificate "
);
spdlog
::
info
(
__FUNCTION__
);
lock_guard
<
recursive_mutex
>
lock
(
m
);
LOCK
(
m
)
return
signCertificateImpl
(
csr
,
autoSign
);
return
signCertificateImpl
(
csr
,
autoSign
);
}
}
Json
::
Value
SGXRegistrationServer
::
GetCertificate
(
const
string
&
hash
)
{
Json
::
Value
SGXRegistrationServer
::
GetCertificate
(
const
string
&
hash
)
{
lock_guard
<
recursive_mutex
>
lock
(
m
);
spdlog
::
info
(
__FUNCTION__
);
LOCK
(
m
)
return
GetSertificateImpl
(
hash
);
return
GetSertificateImpl
(
hash
);
}
}
...
...
testw.cpp
View file @
f579eb35
...
@@ -769,6 +769,13 @@ TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") {
...
@@ -769,6 +769,13 @@ TEST_CASE_METHOD(TestFixture, "Get ServerStatus", "[get-server-status]") {
}
}
TEST_CASE_METHOD
(
TestFixture
,
"Cert request sign ServerStatus"
,
"[cert-sign]"
)
{
HttpClient
client
(
RPC_ENDPOINT
);
StubClient
c
(
client
,
JSONRPC_CLIENT_V2
);
REQUIRE
(
c
.
getServerStatus
()[
"status"
]
==
0
);
}
TEST_CASE_METHOD
(
TestFixture
,
"DKG API test"
,
"[dkg-api]"
)
{
TEST_CASE_METHOD
(
TestFixture
,
"DKG API test"
,
"[dkg-api]"
)
{
...
...
testw.h
View file @
f579eb35
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
#define SAMPLE_DKG_PUB_KEY_2 "378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25"
#define SAMPLE_DKG_PUB_KEY_2 "378b3e6fdfe2633256ae1662fcd23466d02ead907b5d4366136341cea5e46f5a7bb67d897d6e35f619810238aa143c416f61c640ed214eb9c67a34c4a31b7d25"
//openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr^
#define SAMPLE_CSR_FILE_NAME "samples/yourdomain.csr"
#endif //SGXWALLET_TESTW_H
#endif //SGXWALLET_TESTW_H
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