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
3d23ab77
Unverified
Commit
3d23ab77
authored
May 07, 2020
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-2536-fix-cert
parent
ed41bdb2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
20 deletions
+53
-20
SGXRegistrationServer.cpp
SGXRegistrationServer.cpp
+17
-6
SGXRegistrationServer.h
SGXRegistrationServer.h
+15
-10
testw.cpp
testw.cpp
+21
-4
No files found.
SGXRegistrationServer.cpp
View file @
3d23ab77
...
...
@@ -87,18 +87,23 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
}
string
genCert
=
string
(
"cd "
)
+
CERT_DIR
+
"&& ./"
+
CERT_CREATE_COMMAND
+
" "
+
hash
;
if
(
system
((
"rm -f "
+
csr_name
).
c_str
())
!=
0
)
{
spdlog
::
error
(
"could not delete csr file"
);
}
string
genCert
=
string
(
"cd "
)
+
CERT_DIR
+
"&& ./"
+
CERT_CREATE_COMMAND
+
" "
+
hash
;
if
(
system
(
genCert
.
c_str
())
==
0
)
{
spdlog
::
info
(
"C
LIENT CERTIFICATE IS SUCCESSFULLY GENERATED
"
);
spdlog
::
info
(
"C
lient cert "
+
hash
+
" generated
"
);
string
db_key
=
"CSR:HASH:"
+
hash
+
"STATUS:"
;
string
status
=
"0"
;
LevelDB
::
getCsrStatusDb
()
->
writeDataUnique
(
db_key
,
status
);
if
(
system
((
"rm -f "
+
csr_name
).
c_str
())
!=
0
)
{
spdlog
::
error
(
"could not delete csr file"
);
}
}
else
{
spdlog
::
error
(
"CLIENT CERTIFICATE GENERATION FAILED"
);
spdlog
::
error
(
"Client cert generation failed: {} "
,
genCert
);
throw
SGXException
(
FAIL_TO_CREATE_CERTIFICATE
,
"CLIENT CERTIFICATE GENERATION FAILED"
);
}
}
else
{
...
...
@@ -184,3 +189,9 @@ int SGXRegistrationServer::initRegistrationServer(bool _autoSign) {
return
0
;
}
shared_ptr
<
SGXRegistrationServer
>
SGXRegistrationServer
::
getServer
()
{
CHECK_STATE
(
server
);
return
server
;
}
SGXRegistrationServer.h
View file @
3d23ab77
...
...
@@ -38,26 +38,31 @@
using
namespace
jsonrpc
;
using
namespace
std
;
class
SGXRegistrationServer
:
public
AbstractRegServer
{
class
SGXRegistrationServer
:
public
AbstractRegServer
{
recursive_mutex
m
;
bool
autoSign
;
static
shared_ptr
<
SGXRegistrationServer
>
server
;
static
shared_ptr
<
HttpServer
>
httpServer
;
static
shared_ptr
<
HttpServer
>
httpServer
;
static
shared_ptr
<
SGXRegistrationServer
>
server
;
public
:
static
shared_ptr
<
SGXRegistrationServer
>
getServer
();
SGXRegistrationServer
(
AbstractServerConnector
&
connector
,
serverVersion_t
type
,
bool
_autoSign
=
false
);
virtual
Json
::
Value
SignCertificate
(
const
string
&
csr
);
virtual
Json
::
Value
GetCertificate
(
const
string
&
hash
);
virtual
Json
::
Value
SignCertificate
(
const
string
&
csr
);
virtual
Json
::
Value
GetCertificate
(
const
string
&
hash
);
static
int
initRegistrationServer
(
bool
_autoSign
=
false
);
};
#endif // SGXD_SGXREGISTRATIONSERVER_H
\ No newline at end of file
testw.cpp
View file @
3d23ab77
...
...
@@ -69,6 +69,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <thread>
#include "common.h"
#include "stubclient.h"
#include "SGXRegistrationServer.h"
#include "SGXWalletServer.h"
#include "testw.h"
...
...
@@ -303,9 +304,23 @@ public:
~
TestFixture
()
{
destroyEnclave
();
}
};
class
TestFixtureHTTPS
{
public
:
TestFixtureHTTPS
()
{
resetDB
();
setOptions
(
false
,
false
,
true
,
true
);
initAll
(
0
,
false
,
true
);
}
~
TestFixtureHTTPS
()
{
destroyEnclave
();
}
};
TEST_CASE_METHOD
(
TestFixture
,
"ECDSA keygen and signature test"
,
"[ecdsa-key-sig-gen]"
)
{
...
...
@@ -769,10 +784,12 @@ 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
(
TestFixtureHTTPS
,
"Cert request sign"
,
"[cert-sign]"
)
{
REQUIRE
(
SGXRegistrationServer
::
getServer
()
!=
nullptr
);
auto
result
=
SGXRegistrationServer
::
getServer
()
->
SignCertificate
(
"Haha"
);
REQUIRE
(
result
[
"status"
]
==
0
);
}
...
...
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