Why my SSL client/server doesn't work?



  • Hi everybody.
    I wrote a client and server that use SSL to communicate but they don't work.
    Here is the code I wrote

    Server:
    @
    void LanServer::incomingConnection(int socketDescriptor){
    //LanServer inherits from QTcpServer
    /tcpSocket is a pointer to a QSslSocket allocated on the heap in LanServer constructor/
    if (!tcpSocket->setSocketDescriptor(socketDescriptor)) {
    emit error(tcpSocket->error());
    return;
    }
    tcpSocket->startServerEncryption();
    }
    @

    Client:
    @
    void LanClient::ConnectToHost(){
    //LanClient inherits from QObject
    /tcpSocket is a pointer to a QSslSocket allocated on the heap in LanClient constructor/
    tcpSocket->connectToHost("localhost",7677);
    if(!tcpSocket->waitForConnected())
    emit CantConnect();
    tcpSocket->startClientEncryption();
    if(!tcpSocket->waitForEncrypted())
    emit CantConnect(); //This is always executed
    }
    @

    Can you please help me solve this problem?



  • check if incomingConnection is called... A friend encountered that problem also when he tried to rewrite incomingConnection...



  • It's called and the connection is established, what fails is the encryption


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.