I’m using a TCP Client Server Library called Lacewing.
http://lacewing-project.org/docs/
What I noticed is that messages I send and receive are in plain text. Is there a way to encrypt / decrypt the messages easily given that I use TCP? How could I add something like TLS en.wikipedia.org/wiki/Transport_Layer_Security or similar?
Thanks
The library is pretty high level but here is client server in a nutshell:
#include <string>
#include <iostream>
#define LacewingFunction
#include "Lacewing.h"
void onReceive (Lacewing::Server &Server, Lacewing::Server::Client &Client,
char * Data, int Size) {
/* callback body */
std::cout << Data << "\n";
}
void onConnect (Lacewing::Server &Server, Lacewing::Server::Client &Client)
{
std::cout << "Connected!" << "\n";
Client.Send("TestingS");
}
void onReceiveC (Lacewing::Client &Client, char * Data, int Size)
{
std::cout << Data << "\n";
Client.Send("TesingC");
}
int main(int argc, char* argv[])
{
std::string s;
std::cin >> s;
if(s == "server")
{
Lacewing::EventPump pump;
Lacewing::Server* server = new Lacewing::Server(pump);
server->onReceive(onReceive);
server->onConnect(onConnect);
server->Host(1234);
pump.StartEventLoop();
}
else
{
Lacewing::EventPump pump;
Lacewing::Client* server = new Lacewing::Client(pump);
server->onReceive(onReceiveC);
server->Connect("192.168.2.12",1234);
pump.StartEventLoop();
}
return 0;
}
In a word: yes. Your two basic options are SSL/TLS and IPsec. SSL would be implemented in your application; IPsec would be outside of your control.
See this answer to a related question.
You’d have to post some of your networking code if you want help on how to adapt it to SSL/TLS.
Edit: If you don’t want to modify the source code to Lacewing, it seems to me that the easiest solution for you might be to use something like stunnel to protect your traffic.