Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

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