Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
Forum Updated to NodeBB v4.3 + New Features

qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chaki
    wrote on last edited by
    #1

    Hello!
    I've written the Fortune Client, which works great. Now, I want to implement the QsslSocket to get an encrypted connection, after the Server answers with welcome, but I do always the error:
    qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
    This is the code:
    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , socket(new QSslSocket(this))
    , ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    qDebug() << QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString();

    tcpSocket = new QTcpSocket(this);
    
    mIn.setDevice(tcpSocket);
    mIn.setVersion(QDataStream::Qt_5_0);
    
    connect(tcpSocket, &QIODevice::readyRead, this, &MainWindow::readServer);
    connect(tcpSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),this, &MainWindow::displayError);
    

    }

    void MainWindow::messageHandler(QStringList answer){

    if(answer[0] == "welcomeToServer"){
        qDebug()<<"Encryption started";
                 QSslSocket *tsocket = new QSslSocket(this);
                 connect(tsocket, &QIODevice::readyRead, this, &MainWindow::readServer);
                 tsocket->connectToHostEncrypted("Example.com", 993);
                 tsocket->waitForReadyRead();
    

    hope You can help me

    Pablo J. RoginaP 1 Reply Last reply
    0
    • M Offline
      M Offline
      Malaluigi
      wrote on last edited by
      #2

      I have exactly the same problem and searching for a solution but cant find one !!

      1 Reply Last reply
      0
      • C Chaki

        Hello!
        I've written the Fortune Client, which works great. Now, I want to implement the QsslSocket to get an encrypted connection, after the Server answers with welcome, but I do always the error:
        qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
        This is the code:
        MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , socket(new QSslSocket(this))
        , ui(new Ui::MainWindow)
        {
        ui->setupUi(this);
        qDebug() << QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString();

        tcpSocket = new QTcpSocket(this);
        
        mIn.setDevice(tcpSocket);
        mIn.setVersion(QDataStream::Qt_5_0);
        
        connect(tcpSocket, &QIODevice::readyRead, this, &MainWindow::readServer);
        connect(tcpSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),this, &MainWindow::displayError);
        

        }

        void MainWindow::messageHandler(QStringList answer){

        if(answer[0] == "welcomeToServer"){
            qDebug()<<"Encryption started";
                     QSslSocket *tsocket = new QSslSocket(this);
                     connect(tsocket, &QIODevice::readyRead, this, &MainWindow::readServer);
                     tsocket->connectToHostEncrypted("Example.com", 993);
                     tsocket->waitForReadyRead();
        

        hope You can help me

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @Chaki What if you go through this example?

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          What version of Qt are you using ?
          On what platform ?
          What version of OpenSSL ?
          How did you install everything ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            What version of Qt are you using ?
            On what platform ?
            What version of OpenSSL ?
            How did you install everything ?

            M Offline
            M Offline
            Malaluigi
            wrote on last edited by
            #5

            @SGaist
            5.14
            Windows
            What do i need to install?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              -> OpenSSL
              Check the Maintenance Tool. IIRC, you can install it from there.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              M 1 Reply Last reply
              0
              • SGaistS SGaist

                -> OpenSSL
                Check the Maintenance Tool. IIRC, you can install it from there.

                M Offline
                M Offline
                Malaluigi
                wrote on last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved