Systemsicherheit/Assignment 7 - SGX Hands-on/SGX101_sample_code-master/RemoteAttestation/Networking/NetworkManagerClient.cpp
Paul Zinselmeyer ba8e969470
All checks were successful
Latex Build / build-latex (Assignment 4 - Protokollsicherheit (Praxis)) (push) Successful in 1m2s
Latex Build / build-latex (Assignment 5 - Software Security - Teil 1) (push) Successful in 1m3s
Latex Build / build-latex (Assignment 6 - Software Security - Teil 2) (push) Successful in 1m0s
Latex Build / build-latex (Assignment 4 - Protokollsicherheit (Praxis)) (pull_request) Successful in 30s
Latex Build / build-latex (Assignment 5 - Software Security - Teil 1) (pull_request) Successful in 10s
Latex Build / build-latex (Assignment 6 - Software Security - Teil 2) (pull_request) Successful in 8s
[Assignment-7] add SGX sample code from VM
2024-06-29 17:55:44 +02:00

75 lines
1.2 KiB
C++

#include "NetworkManagerClient.h"
#include "../GeneralSettings.h"
NetworkManagerClient* NetworkManagerClient::instance = NULL;
NetworkManagerClient::NetworkManagerClient() {}
void NetworkManagerClient::Init() {
if (client) {
delete client;
client = NULL;
}
boost::asio::ip::tcp::resolver resolver(this->io_service);
boost::asio::ip::tcp::resolver::query query(this->host, std::to_string(this->port).c_str());
boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query);
boost::asio::ssl::context ctx(boost::asio::ssl::context::sslv23);
ctx.load_verify_file(Settings::server_crt);
this->client = new Client(io_service, ctx, iterator);
}
NetworkManagerClient* NetworkManagerClient::getInstance(int port, std::string host) {
if (instance == NULL) {
instance = new NetworkManagerClient();
instance->setPort(port);
instance->setHost(host);
}
return instance;
}
void NetworkManagerClient::startService() {
this->client->startConnection();
}
void NetworkManagerClient::setHost(std::string host) {
this->host = host;
}
void NetworkManagerClient::connectCallbackHandler(CallbackHandler cb) {
this->client->setCallbackHandler(cb);
}