Unverified Commit d876778a authored by Oleh Nikolaiev's avatar Oleh Nikolaiev Committed by GitHub

Merge branch 'develop' into enhancement/SKALE-2941-interactive-mode

parents a1796198 681cbd3b
......@@ -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;
......
......@@ -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;
......
......@@ -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)
......
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