Unverified Commit a86223fe authored by kladko's avatar kladko

Fixed docs

parent 0e270582
...@@ -51,8 +51,8 @@ int useHTTPS = -1; ...@@ -51,8 +51,8 @@ int useHTTPS = -1;
int encryptKeys = -1; int encryptKeys = -1;
int autoconfirm = -1; int autoconfirm = -1;
SGXRegistrationServer *registrationServer = nullptr; shared_ptr <SGXRegistrationServer> SGXRegistrationServer::server = nullptr;
HttpServer *httpServer2 = nullptr; shared_ptr <HttpServer> SGXRegistrationServer::httpServer = nullptr;
SGXRegistrationServer::SGXRegistrationServer(AbstractServerConnector &connector, SGXRegistrationServer::SGXRegistrationServer(AbstractServerConnector &connector,
serverVersion_t type, bool _autoSign) serverVersion_t type, bool _autoSign)
...@@ -60,13 +60,13 @@ SGXRegistrationServer::SGXRegistrationServer(AbstractServerConnector &connector, ...@@ -60,13 +60,13 @@ SGXRegistrationServer::SGXRegistrationServer(AbstractServerConnector &connector,
Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) { Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
spdlog::info(__FUNCTION__);
INIT_RESULT(result) INIT_RESULT(result)
result["result"] = false; result["result"] = false;
try { try {
spdlog::info(__FUNCTION__);
string status = "1"; string status = "1";
string hash = cryptlite::sha256::hash_hex(_csr); string hash = cryptlite::sha256::hash_hex(_csr);
...@@ -115,16 +115,15 @@ Json::Value getCertificateImpl(const string &hash) { ...@@ -115,16 +115,15 @@ Json::Value getCertificateImpl(const string &hash) {
string cert; string cert;
try { try {
string db_key = "CSR:HASH:" + hash + "STATUS:"; string db_key = "CSR:HASH:" + hash + "STATUS:";
shared_ptr<string> status_str_ptr = LevelDB::getCsrStatusDb()->readString(db_key); shared_ptr <string> status_str_ptr = LevelDB::getCsrStatusDb()->readString(db_key);
if (status_str_ptr == nullptr) { if (status_str_ptr == nullptr) {
throw SGXException(KEY_SHARE_DOES_NOT_EXIST, "Data with this name does not exist in csr db"); throw SGXException(KEY_SHARE_DOES_NOT_EXIST, "Data with this name does not exist in csr db");
} }
int status = atoi(status_str_ptr->c_str()); int status = atoi(status_str_ptr->c_str());
if (status == 0) { if (status == 0) {
string crt_name = "cert/" + hash + ".crt"; string crtPath = "cert/" + hash + ".crt";
//if (access(crt_name.c_str(), F_OK) == 0){ ifstream infile(crtPath);
ifstream infile(crt_name);
if (!infile.is_open()) { if (!infile.is_open()) {
string status_db_key = "CSR:HASH:" + hash + "STATUS:"; string status_db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->deleteKey(status_db_key); LevelDB::getCsrStatusDb()->deleteKey(status_db_key);
...@@ -170,16 +169,14 @@ Json::Value SGXRegistrationServer::GetCertificate(const string &hash) { ...@@ -170,16 +169,14 @@ Json::Value SGXRegistrationServer::GetCertificate(const string &hash) {
} }
int SGXRegistrationServer::initRegistrationServer(bool _autoSign) { int SGXRegistrationServer::initRegistrationServer(bool _autoSign) {
httpServer2 = new HttpServer(BASE_PORT + 1); httpServer = make_shared<HttpServer>(BASE_PORT + 1);
registrationServer = new SGXRegistrationServer(*httpServer2, server = make_shared<SGXRegistrationServer>(*httpServer,
JSONRPC_SERVER_V2, JSONRPC_SERVER_V2,
_autoSign); // hybrid server (json-rpc 1.0 & 2.0) _autoSign); // hybrid server (json-rpc 1.0 & 2.0)
if (!registrationServer->StartListening()) { if (!server->StartListening()) {
spdlog::info("Registration server could not start listening"); spdlog::info("Registration server could not start listening");
exit(-1); exit(-1);
} else { } else {
......
...@@ -25,9 +25,13 @@ ...@@ -25,9 +25,13 @@
#define SGXD_SGXREGISTRATIONSERVER_H #define SGXD_SGXREGISTRATIONSERVER_H
#include "abstractregserver.h"
#include <mutex> #include <mutex>
#include "abstractregserver.h"
#include <jsonrpccpp/server/connectors/httpserver.h>
using namespace jsonrpc; using namespace jsonrpc;
using namespace std; using namespace std;
...@@ -35,6 +39,8 @@ class SGXRegistrationServer: public AbstractRegServer { ...@@ -35,6 +39,8 @@ class SGXRegistrationServer: public AbstractRegServer {
recursive_mutex m; recursive_mutex m;
bool autoSign; bool autoSign;
static shared_ptr<SGXRegistrationServer> server;
static shared_ptr<HttpServer> httpServer;
public: public:
......
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