Hello, after finishing my server/client project, i am concerned about the security of this system. I will run in an local/closed network which can be accessed via VPN. At the moment everybody can send data to the server via telnet or the written client application.
Can somebody explain how to upgrade my server/client code to ssl?
server:
#include "myserver.h"
myServer
::myServer(QObject *parent
) :{
}
void myServer::startServer()
{
{
qDebug()<< "Server online";
}
else
{
qDebug() << "Server offline";
}
}
void myServer::incomingConnection(qintptr handle)
{
myClient *client = new myClient(this);
client->setSocket(handle);
connect(client,SIGNAL(client_done()),this,SLOT(done()));
}
void myServer::done()
{
qDebug() << "Refresh";
emit refreshing();
}
#include "myserver.h"
myServer::myServer(QObject *parent) :
QTcpServer(parent)
{
}
void myServer::startServer()
{
if(listen(QHostAddress::Any,1234))
{
qDebug()<< "Server online";
}
else
{
qDebug() << "Server offline";
}
}
void myServer::incomingConnection(qintptr handle)
{
myClient *client = new myClient(this);
client->setSocket(handle);
connect(client,SIGNAL(client_done()),this,SLOT(done()));
}
void myServer::done()
{
qDebug() << "Refresh";
emit refreshing();
}
To copy to clipboard, switch view to plain text mode
client:
#include "myclient.h"
#include <iostream>
#include <fstream>
#include <string>
#include <QFile>
#include <QTextStream>
using namespace std;
myClient
::myClient(QObject *parent
) :{
socket->connectToHost("192.168.1.109", 1234);
qDebug() << "Connected to Server";
}
void myClient::sendSocket()
{
string line;
ifstream myfile ("send.txt");
if (myfile.is_open())
{
while (getline (myfile,line))
{
if( socket->waitForConnected() )
{
socket->write(line.c_str());
qDebug
() <<
QString::fromStdString(line
);
socket->write("\n");
}
}
myfile.close();
}
qDebug() << "Data transfere completed";
}
#include "myclient.h"
#include <iostream>
#include <fstream>
#include <string>
#include <QFile>
#include <QTextStream>
using namespace std;
myClient::myClient(QObject *parent) :
QObject(parent)
{
socket = new QTcpSocket(this);
socket->connectToHost("192.168.1.109", 1234);
qDebug() << "Connected to Server";
}
void myClient::sendSocket()
{
string line;
ifstream myfile ("send.txt");
if (myfile.is_open())
{
while (getline (myfile,line))
{
if( socket->waitForConnected() )
{
socket->write(line.c_str());
qDebug() << QString::fromStdString(line);
socket->write("\n");
}
}
myfile.close();
}
qDebug() << "Data transfere completed";
}
To copy to clipboard, switch view to plain text mode
Bookmarks