Qiieha
13th January 2012, 12:28
Hi,
I found this code at a linux program. It is a client - server application and this is a part of the client.
The communication is ssl encrypted.
Client::Client(QString host,long port,bool fs)
{
/*if(!serverConnection)*/ serverConnection = new QSslSocket(this);
serverConnection -> setPeerVerifyMode(QSslSocket::QueryPeer);
serverConnection -> setLocalCertificate("mycert.pem");
serverConnection -> setPrivateKey("mycert.pem");
serverConnection -> connectToHostEncrypted( host, port);
peerPort = port;
connected=0;
fileSend=fs;
connect(serverConnection, SIGNAL(encrypted()), SLOT(connectionAccepted()));
connect(serverConnection,SIGNAL(stateChanged(QAbst ractSocket::SocketState)),this, SLOT(socketStateChanged(QAbstractSocket::SocketSta te)));
connect(serverConnection, SIGNAL(readyRead()), this, SLOT(readDataFromServer()));
connect(serverConnection, SIGNAL(disconnected()), serverConnection, SLOT(deleteLater()));
connect(serverConnection, SIGNAL(sslErrors(QList<QSslError>)),SLOT(sslErrors(QList<QSslError>)) );
}
The programmer calls serverConnection -> connectToHostEncrypted( host, port); and after that he connects the signal encrypted() to the slot connectionAccepted();
But it should be connected first, shouldn't it?
I found this code at a linux program. It is a client - server application and this is a part of the client.
The communication is ssl encrypted.
Client::Client(QString host,long port,bool fs)
{
/*if(!serverConnection)*/ serverConnection = new QSslSocket(this);
serverConnection -> setPeerVerifyMode(QSslSocket::QueryPeer);
serverConnection -> setLocalCertificate("mycert.pem");
serverConnection -> setPrivateKey("mycert.pem");
serverConnection -> connectToHostEncrypted( host, port);
peerPort = port;
connected=0;
fileSend=fs;
connect(serverConnection, SIGNAL(encrypted()), SLOT(connectionAccepted()));
connect(serverConnection,SIGNAL(stateChanged(QAbst ractSocket::SocketState)),this, SLOT(socketStateChanged(QAbstractSocket::SocketSta te)));
connect(serverConnection, SIGNAL(readyRead()), this, SLOT(readDataFromServer()));
connect(serverConnection, SIGNAL(disconnected()), serverConnection, SLOT(deleteLater()));
connect(serverConnection, SIGNAL(sslErrors(QList<QSslError>)),SLOT(sslErrors(QList<QSslError>)) );
}
The programmer calls serverConnection -> connectToHostEncrypted( host, port); and after that he connects the signal encrypted() to the slot connectionAccepted();
But it should be connected first, shouldn't it?