Unverified Commit f579eb35 authored by kladko's avatar kladko

SKALE-2536-insecure-samples

parent 8465cb08
...@@ -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);
} }
......
...@@ -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]") {
......
...@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment