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
accfcb7e
Unverified
Commit
accfcb7e
authored
4 years ago
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-4005 add exit code for zmq
parent
0ee16cca
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
6 additions
and
51 deletions
+6
-51
CSRManagerServer.cpp
CSRManagerServer.cpp
+0
-1
ExitHandler.h
ExitHandler.h
+1
-0
LevelDB.cpp
LevelDB.cpp
+0
-2
SEKManager.cpp
SEKManager.cpp
+0
-18
SEKManager.h
SEKManager.h
+0
-2
SGXInfoServer.cpp
SGXInfoServer.cpp
+0
-1
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+0
-1
SGXWalletServer.cpp
SGXWalletServer.cpp
+1
-5
ServerInit.cpp
ServerInit.cpp
+0
-10
ZMQServer.cpp
ZMQServer.cpp
+4
-8
sgxwall.cpp
sgxwall.cpp
+0
-3
No files found.
CSRManagerServer.cpp
View file @
accfcb7e
...
...
@@ -121,7 +121,6 @@ int CSRManagerServer::initCSRManagerServer() {
if
(
!
cs
->
StartListening
())
{
spdlog
::
info
(
"CSR manager server could not start listening"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_starting_server
);
exit
(
-
1
);
}
else
{
spdlog
::
info
(
"CSR manager server started on port {}"
,
BASE_PORT
+
2
);
}
...
...
This diff is collapsed.
Click to expand it.
ExitHandler.h
View file @
accfcb7e
...
...
@@ -18,6 +18,7 @@ public:
ec_creating_certificate
=
200
,
// error creating SSL certificate to initialize server
ec_initing_enclave
=
201
,
// error starting secure enclave
ec_initing_user_space
=
202
,
// error or exception while initializing user space
ec_cannot_start_zeromq
=
203
,
// error starting ZMQ server
};
private
:
...
...
This diff is collapsed.
Click to expand it.
LevelDB.cpp
View file @
accfcb7e
...
...
@@ -277,7 +277,6 @@ void LevelDB::initDataFolderAndDBs() {
if
(
getcwd
(
cwd
,
sizeof
(
cwd
))
==
NULL
)
{
spdlog
::
error
(
"could not get current workin directory"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_creating_database
);
exit
(
-
2
);
}
sgx_data_folder
=
string
(
cwd
)
+
"/"
+
SGXDATA_FOLDER
;
...
...
@@ -292,7 +291,6 @@ void LevelDB::initDataFolderAndDBs() {
else
{
spdlog
::
error
(
"Couldnt create creating sgx_data folder"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_creating_database
);
exit
(
-
3
);
}
}
...
...
This diff is collapsed.
Click to expand it.
SEKManager.cpp
View file @
accfcb7e
...
...
@@ -92,7 +92,6 @@ void validate_SEK() {
BUF_LEN
))
{
spdlog
::
error
(
"Corrupt test key is LevelDB"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_initing_sek
);
exit
(
-
4
);
}
sgx_status_t
status
=
SGX_SUCCESS
;
...
...
@@ -111,7 +110,6 @@ void validate_SEK() {
spdlog
::
error
(
"Set the correct backup key into sgx_datasgxwallet_backup_key.txt"
);
spdlog
::
error
(
"Then run sgxwallet using backup flag"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_initing_sek
);
exit
(
-
5
);
}
}
...
...
@@ -208,19 +206,6 @@ void gen_SEK() {
}
//static std::atomic<int> isSgxWalletExiting(0);
//void safeExit() {
// // this is to make sure exit is only called once if called from multiple threads
// auto previousValue = isSgxWalletExiting.exchange(1);
// if (previousValue != 1)
// exit(-6);
//}
void
setSEK
(
shared_ptr
<
string
>
hex_encrypted_SEK
)
{
CHECK_STATE
(
hex_encrypted_SEK
);
...
...
@@ -260,14 +245,12 @@ void enter_SEK() {
if
(
test_key_ptr
==
nullptr
)
{
spdlog
::
error
(
"Error: corrupt or empty LevelDB database"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_initing_sek
);
exit
(
-
7
);
}
if
(
!
experimental
::
filesystem
::
is_regular_file
(
BACKUP_PATH
))
{
spdlog
::
error
(
"File does not exist: "
BACKUP_PATH
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_initing_sek
);
exit
(
-
8
);
}
ifstream
sek_file
(
BACKUP_PATH
);
...
...
@@ -284,7 +267,6 @@ void enter_SEK() {
while
(
!
checkHex
(
sek
,
16
))
{
spdlog
::
error
(
"Invalid hex in key"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_initing_sek
);
exit
(
-
9
);
}
auto
encrypted_SEK
=
check_and_set_SEK
(
sek
);
...
...
This diff is collapsed.
Click to expand it.
SEKManager.h
View file @
accfcb7e
...
...
@@ -47,8 +47,6 @@ EXTERNC void initSEK();
EXTERNC
void
setSEK
();
//EXTERNC void safeExit();
...
...
This diff is collapsed.
Click to expand it.
SGXInfoServer.cpp
View file @
accfcb7e
...
...
@@ -117,7 +117,6 @@ int SGXInfoServer::initInfoServer(uint32_t _logLevel, bool _autoSign, bool _chec
if
(
!
server
->
StartListening
())
{
spdlog
::
error
(
"Info server could not start listening on port {}"
,
BASE_PORT
+
4
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_starting_server
);
exit
(
-
10
);
}
else
{
spdlog
::
info
(
"Info server started on port {}"
,
BASE_PORT
+
4
);
}
...
...
This diff is collapsed.
Click to expand it.
SGXRegistrationServer.cpp
View file @
accfcb7e
...
...
@@ -174,7 +174,6 @@ int SGXRegistrationServer::initRegistrationServer(bool _autoSign) {
if
(
!
server
->
StartListening
())
{
spdlog
::
error
(
"Registration server could not start listening on port {}"
,
BASE_PORT
+
1
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_starting_server
);
exit
(
-
10
);
}
else
{
spdlog
::
info
(
"Registration server started on port {}"
,
BASE_PORT
+
1
);
}
...
...
This diff is collapsed.
Click to expand it.
SGXWalletServer.cpp
View file @
accfcb7e
...
...
@@ -143,7 +143,6 @@ void SGXWalletServer::createCertsIfNeeded() {
}
else
{
spdlog
::
error
(
"ROOT CA CERTIFICATE GENERATION FAILED"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_creating_certificate
);
exit
(
-
11
);
}
}
...
...
@@ -161,7 +160,6 @@ void SGXWalletServer::createCertsIfNeeded() {
}
else
{
spdlog
::
info
(
"SERVER CERTIFICATE GENERATION FAILED"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_creating_certificate
);
exit
(
-
12
);
}
}
...
...
@@ -172,7 +170,6 @@ void SGXWalletServer::createCertsIfNeeded() {
}
else
{
spdlog
::
info
(
"SERVER CERTIFICATE VERIFICATION FAILED"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_creating_certificate
);
exit
(
-
12
);
}
}
...
...
@@ -198,7 +195,6 @@ int SGXWalletServer::initHttpsServer(bool _checkCerts) {
if
(
!
server
->
StartListening
())
{
spdlog
::
error
(
"SGX Server could not start listening"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_starting_server
);
exit
(
-
13
);
}
else
{
spdlog
::
info
(
"SGX Server started on port {}"
,
BASE_PORT
);
}
...
...
@@ -218,8 +214,8 @@ int SGXWalletServer::initHttpServer() { //without ssl
if
(
!
server
->
StartListening
())
{
spdlog
::
error
(
"Server could not start listening"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_error_starting_server
);
exit
(
-
14
);
}
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
ServerInit.cpp
View file @
accfcb7e
...
...
@@ -72,7 +72,6 @@ void systemHealthCheck() {
}
catch
(...)
{
spdlog
::
error
(
"Execution of '/bin/bash -c ulimit -n' failed"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_initing_user_space
);
exit
(
-
15
);
}
int
noFiles
=
strtol
(
ulimit
.
c_str
(),
NULL
,
10
);
...
...
@@ -87,13 +86,9 @@ void systemHealthCheck() {
"After that, restart sgxwallet"
;
spdlog
::
error
(
errStr
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_initing_user_space
);
exit
(
-
16
);
}
}
void
initUserSpace
()
{
libff
::
inhibit_profiling_counters
=
true
;
...
...
@@ -120,7 +115,6 @@ uint64_t initEnclave() {
if
(
!
SGX_OK
(
support
))
{
sgx_support_perror
(
support
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_initing_enclave
);
exit
(
-
17
);
}
#endif
...
...
@@ -152,7 +146,6 @@ uint64_t initEnclave() {
spdlog
::
error
(
"sgx_create_enclave_search failed {} {}"
,
ENCLAVE_NAME
,
status
);
}
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_initing_enclave
);
exit
(
-
21
);
}
spdlog
::
info
(
"Enclave created and started successfully"
);
...
...
@@ -228,18 +221,15 @@ void initAll(uint32_t _logLevel, bool _checkCert,
}
catch
(
SGXException
&
_e
)
{
spdlog
::
error
(
_e
.
getMessage
());
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_initing_user_space
);
exit
(
-
18
);
}
catch
(
exception
&
_e
)
{
spdlog
::
error
(
_e
.
what
());
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_initing_user_space
);
exit
(
-
19
);
}
catch
(...)
{
exception_ptr
p
=
current_exception
();
printf
(
"Exception %s
\n
"
,
p
.
__cxa_exception_type
()
->
name
());
spdlog
::
error
(
"Unknown exception"
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_initing_user_space
);
exit
(
-
22
);
}
};
...
...
This diff is collapsed.
Click to expand it.
ZMQServer.cpp
View file @
accfcb7e
...
...
@@ -79,8 +79,7 @@ void ZMQServer::run() {
frontend
->
bind
(
"tcp://*:"
+
to_string
(
port
));
}
catch
(...)
{
spdlog
::
error
(
"Server task could not bind to port:{}"
,
port
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_failure
);
exit
(
ZMQ_COULD_NOT_BIND_FRONT_END
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_cannot_start_zeromq
);
}
spdlog
::
info
(
"Bound port ..."
);
...
...
@@ -90,8 +89,7 @@ void ZMQServer::run() {
backend
->
bind
(
"inproc://backend"
);
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"Could not bind to zmq backend: {}"
,
e
.
what
());
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_failure
);
exit
(
ZMQ_COULD_NOT_BIND_BACK_END
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_cannot_start_zeromq
);
}
...
...
@@ -106,8 +104,7 @@ void ZMQServer::run() {
}
}
catch
(
std
::
exception
&
e
)
{
spdlog
::
error
(
"Could not create zmq server workers:{} "
,
e
.
what
());
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_failure
);
exit
(
ZMQ_COULD_NOT_CREATE_WORKERS
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_cannot_start_zeromq
);
};
...
...
@@ -127,8 +124,7 @@ void ZMQServer::run() {
return
;
}
spdlog
::
info
(
"Error, exiting zmq server ..."
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_failure
);
exit
(
ZMQ_COULD_NOT_CREATE_PROXY
);
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_cannot_start_zeromq
);
}
}
...
...
This diff is collapsed.
Click to expand it.
sgxwall.cpp
View file @
accfcb7e
...
...
@@ -100,7 +100,6 @@ int main(int argc, char *argv[]) {
if
(
argc
>
1
&&
strlen
(
argv
[
1
])
==
1
)
{
SGXWallet
::
printUsage
();
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_failure
);
exit
(
-
22
);
}
while
((
opt
=
getopt
(
argc
,
argv
,
"cshd0abyvVnT"
))
!=
-
1
)
{
...
...
@@ -108,7 +107,6 @@ int main(int argc, char *argv[]) {
case
'h'
:
SGXWallet
::
printUsage
();
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_failure
);
exit
(
-
24
);
case
'c'
:
checkClientCertOption
=
false
;
break
;
...
...
@@ -146,7 +144,6 @@ int main(int argc, char *argv[]) {
default
:
SGXWallet
::
printUsage
();
ExitHandler
::
exitHandler
(
SIGTERM
,
ExitHandler
::
ec_failure
);
exit
(
-
23
);
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
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