Changing QTcpServer to SSL Server
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:
Code:
#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();
}
client:
Code:
#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";
}
Re: Changing QTcpServer to SSL Server
Use QSslsocket instead of QTcpSocket on both sides.
On the client side, call connecToHostEncrypted() instead of connectToHost().
On the server side, call startServerEncryption().
See http://qt-project.org/doc/qt-5/QSslSocket.html#details
Cheers,
_
Re: Changing QTcpServer to SSL Server
Hi thank you, if i just change mit TcpSocket to SslSocket und the way of connection, my server is giving me this error msg
QSslSocket: cannot call unresolved function SSLv23_server_method
QSslSocket: cannot call unresolved function SSL_CTX_new
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function ERR_get_error
QSslSocket: cannot call unresolved function ERR_get_error
when i try to connect via my client.
Re: Changing QTcpServer to SSL Server
Looks like the OpenSSL library is not found or not installed
Cheers,
_
Re: Changing QTcpServer to SSL Server
I have just reinstalled OpenSSL for Win but the error is the same :(
Re: Changing QTcpServer to SSL Server
I am not exactly sure where Qt on Windows is looking for OpenSSL, maybe some of the people using Qt in that platform can help here?
Cheers,
_
Re: Changing QTcpServer to SSL Server
Hi, just wanted to update you guys, i have written a simple encrytion myselfe and protected the server via a password. Its not as secure as ssl but it does the job. :)
thanks for the help! this thread can be closed
Re: Changing QTcpServer to SSL Server
Quote:
Originally Posted by
anda_skoa
I am not exactly sure where Qt on Windows is looking for OpenSSL, maybe some of the people using Qt in that platform can help here?
Qt will call LoadLibrary to see if the OpenSSL library can be used. Windows will search the program binary folder then the PATH and Windows system directories looking for it (i.e. The standard Windows behaviour).