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
1bf64e42
Unverified
Commit
1bf64e42
authored
Dec 11, 2020
by
Oleh Nikolaiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-3023 add serverConfiguration command
parent
8cc1d2c4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
34 deletions
+50
-34
SGXInfoServer.cpp
SGXInfoServer.cpp
+17
-11
SGXInfoServer.h
SGXInfoServer.h
+7
-3
ServerInit.cpp
ServerInit.cpp
+2
-2
ServerInit.h
ServerInit.h
+1
-1
sgx_util.cpp
sgx_util.cpp
+18
-12
sgxwall.cpp
sgxwall.cpp
+1
-1
testw.cpp
testw.cpp
+4
-4
No files found.
SGXInfoServer.cpp
View file @
1bf64e42
...
...
@@ -43,8 +43,14 @@
shared_ptr
<
SGXInfoServer
>
SGXInfoServer
::
server
=
nullptr
;
shared_ptr
<
HttpServer
>
SGXInfoServer
::
httpServer
=
nullptr
;
SGXInfoServer
::
SGXInfoServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
)
:
AbstractInfoServer
(
connector
,
type
)
{}
SGXInfoServer
::
SGXInfoServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
,
uint32_t
_logLevel
,
bool
_autoSign
,
bool
_checkCerts
,
bool
_generateTestKeys
)
:
AbstractInfoServer
(
connector
,
type
)
{
logLevel_
=
_logLevel
;
autoSign_
=
_autoSign
;
checkCerts_
=
_checkCerts
;
generateTestKeys_
=
_generateTestKeys
;
}
Json
::
Value
SGXInfoServer
::
getAllKeysInfo
()
{
Json
::
Value
result
;
...
...
@@ -72,13 +78,13 @@ Json::Value SGXInfoServer::getServerConfiguration() {
Json
::
Value
result
;
try
{
result
[
"autoConfirm"
]
=
false
;
result
[
"logLevel"
]
=
false
;
result
[
"en
claveLogLevel"
]
=
false
;
result
[
"
backupOption"
]
=
false
;
result
[
"
HTTPS"
]
=
false
;
result
[
"
autoSign"
]
=
false
;
result
[
"
createTestKeys"
]
=
false
;
result
[
"autoConfirm"
]
=
autoconfirm
;
result
[
"logLevel"
]
=
logLevel_
;
result
[
"en
terBackupKey"
]
=
enterBackupKey
;
result
[
"
useHTTPS"
]
=
useHTTPS
;
result
[
"
autoSign"
]
=
autoSign_
;
result
[
"
checkCerts"
]
=
checkCerts_
;
result
[
"
generateTestKeys"
]
=
generateTestKeys_
;
}
HANDLE_SGX_EXCEPTION
(
result
)
RETURN_SUCCESS
(
result
)
...
...
@@ -99,9 +105,9 @@ Json::Value SGXInfoServer::isKeyExist(const string& key) {
RETURN_SUCCESS
(
result
)
}
int
SGXInfoServer
::
initInfoServer
()
{
int
SGXInfoServer
::
initInfoServer
(
uint32_t
_logLevel
,
bool
_autoSign
,
bool
_checkCerts
,
bool
_generateTestKeys
)
{
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
+
5
);
server
=
make_shared
<
SGXInfoServer
>
(
*
httpServer
,
JSONRPC_SERVER_V2
);
// hybrid server (json-rpc 1.0 & 2.0)
server
=
make_shared
<
SGXInfoServer
>
(
*
httpServer
,
JSONRPC_SERVER_V2
,
_logLevel
,
_autoSign
,
_checkCerts
,
_generateTestKeys
);
// hybrid server (json-rpc 1.0 & 2.0)
if
(
!
server
->
StartListening
())
{
spdlog
::
error
(
"Info server could not start listening on port {}"
,
BASE_PORT
+
5
);
...
...
SGXInfoServer.h
View file @
1bf64e42
...
...
@@ -35,7 +35,10 @@ using namespace std;
class
SGXInfoServer
:
public
AbstractInfoServer
{
recursive_mutex
m
;
bool
autoSign
;
uint32_t
logLevel_
;
bool
autoSign_
;
bool
checkCerts_
;
bool
generateTestKeys_
;
static
shared_ptr
<
HttpServer
>
httpServer
;
...
...
@@ -45,7 +48,8 @@ public:
static
shared_ptr
<
SGXInfoServer
>
getServer
();
SGXInfoServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
);
SGXInfoServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
,
uint32_t
_logLevel
,
bool
_autoSign
,
bool
_checkCerts
,
bool
_generateTestKeys
);
virtual
Json
::
Value
getAllKeysInfo
();
...
...
@@ -55,7 +59,7 @@ public:
virtual
Json
::
Value
isKeyExist
(
const
string
&
key
);
static
int
initInfoServer
();
static
int
initInfoServer
(
uint32_t
_logLevel
,
bool
_autoSign
,
bool
_checkCerts
,
bool
_generateTestKeys
);
};
...
...
ServerInit.cpp
View file @
1bf64e42
...
...
@@ -163,7 +163,7 @@ uint64_t initEnclave() {
void
initAll
(
uint32_t
_logLevel
,
bool
_checkCert
,
bool
_autoSign
)
{
void
initAll
(
uint32_t
_logLevel
,
bool
_checkCert
,
bool
_autoSign
,
bool
_generateTestKeys
)
{
static
atomic
<
bool
>
sgxServerInited
(
false
);
static
mutex
initMutex
;
...
...
@@ -203,7 +203,7 @@ void initAll(uint32_t _logLevel, bool _checkCert, bool _autoSign) {
}
else
{
SGXWalletServer
::
initHttpServer
();
}
SGXInfoServer
::
initInfoServer
();
SGXInfoServer
::
initInfoServer
(
_logLevel
,
_checkCert
,
_autoSign
,
_generateTestKeys
);
sgxServerInited
=
true
;
}
catch
(
SGXException
&
_e
)
{
...
...
ServerInit.h
View file @
1bf64e42
...
...
@@ -32,7 +32,7 @@
#define EXTERNC
#endif
EXTERNC
void
initAll
(
uint32_t
_logLevel
,
bool
_checkCert
,
bool
_autoSign
);
EXTERNC
void
initAll
(
uint32_t
_logLevel
,
bool
_checkCert
,
bool
_autoSign
,
bool
_generateTestKeys
);
EXTERNC
void
initUserSpace
();
...
...
sgx_util.cpp
View file @
1bf64e42
...
...
@@ -29,19 +29,19 @@
#include <unistd.h>
int
print_hashes
(){
jsonrpc
::
HttpClient
client
(
"http://localhost:1028"
);
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
std
::
cout
<<
"Client inited"
<<
std
::
endl
;
std
::
cout
<<
c
.
getUnsignedCSRs
()
<<
std
::
endl
;
exit
(
0
);
jsonrpc
::
HttpClient
client
(
"http://localhost:1028"
);
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
std
::
cout
<<
"Client inited"
<<
std
::
endl
;
std
::
cout
<<
c
.
getUnsignedCSRs
()
<<
std
::
endl
;
exit
(
0
);
}
void
sign_by_hash
(
std
::
string
&
hash
,
int
status
){
jsonrpc
::
HttpClient
client
(
"http://localhost:1028"
);
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
std
::
cout
<<
"Client inited"
<<
std
::
endl
;
std
::
cout
<<
c
.
signByHash
(
hash
,
status
)
<<
std
::
endl
;
exit
(
0
);
jsonrpc
::
HttpClient
client
(
"http://localhost:1028"
);
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
std
::
cout
<<
"Client inited"
<<
std
::
endl
;
std
::
cout
<<
c
.
signByHash
(
hash
,
status
)
<<
std
::
endl
;
exit
(
0
);
}
void
getAllKeysInfo
()
{
...
...
@@ -67,7 +67,13 @@ void getServerConfiguration() {
StubClient
c
(
client
,
jsonrpc
::
JSONRPC_CLIENT_V2
);
std
::
cout
<<
"Info client inited"
<<
std
::
endl
;
Json
::
Value
response
=
c
.
getServerConfiguration
();
std
::
cout
<<
"OPTION autoConfitm certificates switched to "
<<
response
[
"autoConfitm"
]
<<
'\n'
;
std
::
cout
<<
"OPTION logLevel switched to "
<<
response
[
"logLevel"
]
<<
'\n'
;
std
::
cout
<<
"OPTION enterBackupKey switched to "
<<
response
[
"enterBackupKey"
]
<<
'\n'
;
std
::
cout
<<
"OPTION useHTTPS switched to "
<<
response
[
"useHTTPS"
]
<<
'\n'
;
std
::
cout
<<
"OPTION autoSign certificates switched to "
<<
response
[
"autoSign"
]
<<
'\n'
;
std
::
cout
<<
"OPTION checkCerts switched to "
<<
response
[
"checkCerts"
]
<<
'\n'
;
std
::
cout
<<
"OPTION generateTestKeys switched to "
<<
response
[
"generateTestKeys"
]
<<
'\n'
;
exit
(
0
);
}
...
...
@@ -103,7 +109,7 @@ int main(int argc, char *argv[]) {
exit
(
0
);
}
std
::
string
hash
;
while
((
opt
=
getopt
(
argc
,
argv
,
"ps:r:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"ps:r:
alci:
"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'p'
:
print_hashes
();
break
;
...
...
sgxwall.cpp
View file @
1bf64e42
...
...
@@ -171,7 +171,7 @@ int main(int argc, char *argv[]) {
enclaveLogLevel
=
L_TRACE
;
}
initAll
(
enclaveLogLevel
,
checkClientCertOption
,
autoSignClientCertOption
);
initAll
(
enclaveLogLevel
,
checkClientCertOption
,
autoSignClientCertOption
,
generateTestKeys
);
ifstream
is
(
"sgx_data/4node.json"
);
...
...
testw.cpp
View file @
1bf64e42
...
...
@@ -72,7 +72,7 @@ public:
TestFixture
()
{
TestUtils
::
resetDB
();
setOptions
(
L_INFO
,
false
,
true
);
initAll
(
L_INFO
,
false
,
true
);
initAll
(
L_INFO
,
false
,
true
,
false
);
}
~
TestFixture
()
{
...
...
@@ -85,7 +85,7 @@ public:
TestFixtureHTTPS
()
{
TestUtils
::
resetDB
();
setOptions
(
L_INFO
,
true
,
true
);
initAll
(
L_INFO
,
false
,
true
);
initAll
(
L_INFO
,
false
,
true
,
false
);
}
~
TestFixtureHTTPS
()
{
...
...
@@ -97,7 +97,7 @@ class TestFixtureNoResetFromBackup {
public
:
TestFixtureNoResetFromBackup
()
{
setFullOptions
(
L_INFO
,
false
,
true
,
true
);
initAll
(
L_INFO
,
false
,
true
);
initAll
(
L_INFO
,
false
,
true
,
false
);
}
~
TestFixtureNoResetFromBackup
()
{
...
...
@@ -110,7 +110,7 @@ class TestFixtureNoReset {
public
:
TestFixtureNoReset
()
{
setOptions
(
L_INFO
,
false
,
true
);
initAll
(
L_INFO
,
false
,
true
);
initAll
(
L_INFO
,
false
,
true
,
false
);
}
~
TestFixtureNoReset
()
{
...
...
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