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
d876778a
Unverified
Commit
d876778a
authored
Jul 07, 2021
by
Oleh Nikolaiev
Committed by
GitHub
Jul 07, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into enhancement/SKALE-2941-interactive-mode
parents
a1796198
681cbd3b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
38 deletions
+23
-38
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+15
-19
SGXRegistrationServer.h
SGXRegistrationServer.h
+1
-1
build_deps.py
scripts/build_deps.py
+7
-18
No files found.
SGXRegistrationServer.cpp
View file @
d876778a
...
...
@@ -59,14 +59,16 @@ SGXRegistrationServer::SGXRegistrationServer(AbstractServerConnector &connector,
:
AbstractRegServer
(
connector
,
type
),
autoSign
(
_autoSign
)
{}
Json
::
Value
signCertificateImpl
(
const
string
&
_csr
,
bool
_autoSign
=
false
)
{
Json
::
Value
SGXRegistrationServer
::
SignCertificate
(
const
string
&
csr
)
{
spdlog
::
info
(
__FUNCTION__
);
INIT_RESULT
(
result
)
result
[
"result"
]
=
false
;
try
{
string
hash
=
cryptlite
::
sha256
::
hash_hex
(
_csr
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
m
);
string
hash
=
cryptlite
::
sha256
::
hash_hex
(
csr
);
if
(
system
(
"ls "
CERT_DIR
"/"
CERT_CREATE_COMMAND
)
!=
0
)
{
spdlog
::
error
(
"cert/create_client_cert does not exist"
);
...
...
@@ -76,7 +78,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
string
csr_name
=
string
(
CERT_DIR
)
+
"/"
+
hash
+
".csr"
;
ofstream
outfile
(
csr_name
);
outfile
.
exceptions
(
std
::
ifstream
::
failbit
|
std
::
ifstream
::
badbit
);
outfile
<<
_
csr
<<
endl
;
outfile
<<
csr
<<
endl
;
outfile
.
close
();
if
(
system
((
"ls "
+
csr_name
).
c_str
())
!=
0
)
{
...
...
@@ -85,12 +87,13 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
}
if
(
system
((
"openssl req -in "
+
csr_name
).
c_str
())
!=
0
)
{
spdlog
::
error
(
"Incorrect CSR format: {}"
,
_
csr
);
spdlog
::
error
(
"Incorrect CSR format: {}"
,
csr
);
throw
SGXException
(
FAIL_TO_CREATE_CERTIFICATE
,
"Incorrect CSR format "
);
}
if
(
_autoSign
)
{
string
genCert
=
string
(
"cd "
)
+
CERT_DIR
+
"&& ./"
+
CERT_CREATE_COMMAND
+
" "
+
hash
;
if
(
autoSign
)
{
string
genCert
=
string
(
"cd "
)
+
CERT_DIR
+
"&& ./"
+
CERT_CREATE_COMMAND
+
" "
+
hash
;
if
(
system
(
genCert
.
c_str
())
==
0
)
{
spdlog
::
info
(
"Client cert "
+
hash
+
" generated"
);
...
...
@@ -98,6 +101,9 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
spdlog
::
error
(
"Client cert generation failed: {} "
,
genCert
);
throw
SGXException
(
FAIL_TO_CREATE_CERTIFICATE
,
"CLIENT CERTIFICATE GENERATION FAILED"
);
}
}
else
{
string
db_key
=
"CSR:HASH:"
+
hash
;
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
db_key
,
csr
);
}
string
db_key
=
"CSR:HASH:"
+
hash
+
"STATUS:"
;
string
status
=
"0"
;
...
...
@@ -111,7 +117,9 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
RETURN_SUCCESS
(
result
)
}
Json
::
Value
getCertificateImpl
(
const
string
&
hash
)
{
Json
::
Value
SGXRegistrationServer
::
GetCertificate
(
const
string
&
hash
)
{
spdlog
::
info
(
__FUNCTION__
);
Json
::
Value
result
;
string
cert
;
...
...
@@ -147,17 +155,6 @@ Json::Value getCertificateImpl(const string &hash) {
}
Json
::
Value
SGXRegistrationServer
::
SignCertificate
(
const
string
&
csr
)
{
spdlog
::
info
(
__FUNCTION__
);
return
signCertificateImpl
(
csr
,
autoSign
);
}
Json
::
Value
SGXRegistrationServer
::
GetCertificate
(
const
string
&
hash
)
{
spdlog
::
info
(
__FUNCTION__
);
return
getCertificateImpl
(
hash
);
}
void
SGXRegistrationServer
::
initRegistrationServer
(
bool
_autoSign
)
{
httpServer
=
make_shared
<
HttpServer
>
(
BASE_PORT
+
1
);
server
=
make_shared
<
SGXRegistrationServer
>
(
*
httpServer
,
...
...
@@ -186,7 +183,6 @@ int SGXRegistrationServer::exitServer() {
return
0
;
}
shared_ptr
<
SGXRegistrationServer
>
SGXRegistrationServer
::
getServer
()
{
CHECK_STATE
(
server
);
return
server
;
...
...
SGXRegistrationServer.h
View file @
d876778a
...
...
@@ -39,7 +39,7 @@ using namespace jsonrpc;
using
namespace
std
;
class
SGXRegistrationServer
:
public
AbstractRegServer
{
recursive_
mutex
m
;
mutex
m
;
bool
autoSign
;
static
shared_ptr
<
HttpServer
>
httpServer
;
...
...
scripts/build_deps.py
View file @
d876778a
...
...
@@ -36,8 +36,6 @@ GMP_DIR = topDir + "/sgx-gmp"
SGX_SDK_DIR_SSL
=
topDir
+
"/sgx-sdk-build/sgxsdk"
ZMQ_DIR
=
topDir
+
"/libzmq"
ZMQ_BUILD_DIR
=
ZMQ_DIR
+
"/build"
CZMQ_DIR
=
topDir
+
"/cppzmq"
CZMQ_BUILD_DIR
=
CZMQ_DIR
+
"/build"
LEVELDB_DIR
=
topDir
+
"/leveldb"
LEVELDB_BUILD_DIR
=
LEVELDB_DIR
+
"/build"
...
...
@@ -64,15 +62,8 @@ subprocess.call(["rm", "-rf", GMP_BUILD_DIR])
subprocess
.
call
([
"rm"
,
"-rf"
,
TGMP_BUILD_DIR
])
subprocess
.
call
([
"rm"
,
"-rf"
,
SDK_DIR
])
assert
subprocess
.
call
([
"cp"
,
"configure.gmp"
,
GMP_DIR
+
"/configure"
])
==
0
print
(
"Build LibBLS"
);
os
.
chdir
(
BLS_DIR
+
"/deps"
)
assert
subprocess
.
call
([
"bash"
,
"-c"
,
"./build.sh"
])
==
0
...
...
@@ -81,7 +72,6 @@ assert subprocess.call(["bash", "-c", "cmake -H. -Bbuild -DBUILD_TESTS=OFF"]) ==
os
.
chdir
(
BLS_DIR
+
"/build"
)
assert
subprocess
.
call
([
"bash"
,
"-c"
,
"make"
])
==
0
print
(
"Build ZMQ"
);
os
.
chdir
(
ZMQ_DIR
)
...
...
@@ -89,7 +79,6 @@ assert subprocess.call(["bash", "-c", "mkdir -p build"]) == 0
os
.
chdir
(
ZMQ_BUILD_DIR
)
assert
subprocess
.
call
([
"bash"
,
"-c"
,
"cmake -DDZMQ_EXPERIMENTAL=1 -DCMAKE_BUILD_TYPE=Release .. && cmake --build ."
])
==
0
print
(
"Build LevelDB"
);
os
.
chdir
(
LEVELDB_DIR
)
...
...
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