Unverified Commit 755819ae authored by kladko's avatar kladko

Seal/unseal fails

parent aa034c4c
...@@ -36,6 +36,10 @@ public: ...@@ -36,6 +36,10 @@ public:
SGXException(int32_t _status, const char* _errString) : status(_status), errString(_errString) {} SGXException(int32_t _status, const char* _errString) : status(_status), errString(_errString) {}
std::string getMessage() {
return "SGXException:status:" + std::to_string(status) + ":" + errString;
}
}; };
#endif //SGXD_RPCEXCEPTION_H #endif //SGXD_RPCEXCEPTION_H
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "CSRManagerServer.h" #include "CSRManagerServer.h"
#include "BLSCrypto.h" #include "BLSCrypto.h"
#include "ServerInit.h" #include "ServerInit.h"
#include "SGXException.h"
#include "SGXWalletServer.hpp" #include "SGXWalletServer.hpp"
void initUserSpace() { void initUserSpace() {
...@@ -104,23 +105,43 @@ void initEnclave(uint32_t _logLevel) { ...@@ -104,23 +105,43 @@ void initEnclave(uint32_t _logLevel) {
spdlog::info("Enclave libtgmp library and logging initialized successfully"); spdlog::info("Enclave libtgmp library and logging initialized successfully");
} }
void initAll(uint32_t _logLevel, bool _checkCert, bool _autoSign) {
static atomic<int> sgxServerInited(0); void initAll(uint32_t _logLevel, bool _checkCert, bool _autoSign) {
cout << "Running sgxwallet version:" << SGXWalletServer::getVersion() << endl; static atomic<bool> sgxServerInited(false);
static mutex initMutex;
CHECK_STATE(sgxServerInited != 1) lock_guard <mutex> lock(initMutex);
sgxServerInited = 1;
initEnclave(_logLevel);
initUserSpace();
initSEK();
if (useHTTPS) { if (sgxServerInited)
SGXWalletServer::initHttpsServer(_checkCert); return;
SGXRegistrationServer::initRegistrationServer(_autoSign);
CSRManagerServer::initCSRManagerServer(); try {
} else {
SGXWalletServer::initHttpServer(); cout << "Running sgxwallet version:" << SGXWalletServer::getVersion() << endl;
CHECK_STATE(sgxServerInited != 1)
sgxServerInited = 1;
initEnclave(_logLevel);
initUserSpace();
initSEK();
if (useHTTPS) {
SGXWalletServer::initHttpsServer(_checkCert);
SGXRegistrationServer::initRegistrationServer(_autoSign);
CSRManagerServer::initCSRManagerServer();
} else {
SGXWalletServer::initHttpServer();
}
sgxServerInited = true;
} catch (SGXException &_e) {
spdlog::error(_e.getMessage());
} catch (exception &_e) {
spdlog::error(_e.what());
} }
} catch (...) {
exception_ptr p = current_exception();
printf("Exception %s \n", p.__cxa_exception_type()->name());
spdlog::error("Unknown exception");
}
};
...@@ -229,14 +229,9 @@ void trustedGenerateSEK(int *errStatus, char *errString, ...@@ -229,14 +229,9 @@ void trustedGenerateSEK(int *errStatus, char *errString,
SAFE_CHAR_BUF(errS, BUF_LEN); SAFE_CHAR_BUF(errS, BUF_LEN);
sprintf(errS, "status $d", status); return;
LOG_ERROR(errS);
CHECK_STATUS("seal/unseal SEK failed after SEK generation in unseal");
// CHECK_STATUS("seal/unseal SEK failed after SEK generation in unseal");
*enc_len = sealedLen; *enc_len = sealedLen;
......
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