Added initial TLS support for socket communication (#41)

* Added initial commit

* Added tls to web sockets which require key file and cert file

* Added meaningful comments
This commit is contained in:
Ravidu Lashan
2019-10-24 14:54:33 +05:30
committed by GitHub
parent 61b38bb0a0
commit 40358890af
12 changed files with 248 additions and 187 deletions

View File

@@ -4,18 +4,21 @@
#include <rapidjson/document.h>
#include <sodium.h>
#include <boost/thread/thread.hpp>
#include "usr.hpp"
#include "user_session_handler.hpp"
#include "../sock/socket_server.hpp"
#include "../sock/socket_session_handler.hpp"
#include "../util.hpp"
#include "../conf.hpp"
#include "../crypto.hpp"
#include "../hplog.hpp"
#include "usr.hpp"
#include "user_session_handler.hpp"
namespace usr
{
// The SSL context is required, and holds certificates
ssl::context ctx{ssl::context::tlsv13};
/**
* Connected (authenticated) user list. (Exposed to other sub systems)
* Map key: User socket session id (<ip:port>)
@@ -249,8 +252,10 @@ int remove_user(const std::string &sessionid)
void start_listening()
{
auto address = net::ip::make_address(conf::cfg.listenip);
std::make_shared<sock::socket_server<user_outbound_message>>(
ioc,
ctx,
tcp::endpoint{address, conf::cfg.pubport},
global_usr_session_handler)
->run();