Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Image: TLS initialization failed
Forum Updated to NodeBB v4.3 + New Features

QML Image: TLS initialization failed

Scheduled Pinned Locked Moved Solved QML and Qt Quick
24 Posts 4 Posters 4.0k Views 3 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.
  • sierdzioS Offline
    sierdzioS Offline
    sierdzio
    Moderators
    wrote on last edited by
    #2

    You need to use OpenSSL in your project - link OpenSSL libs with your application and it should start working.

    Some docs:

    • https://doc.qt.io/qt-5.12/ssl.html
    • https://doc.qt.io/qt-5/android-openssl-support.html

    (Z(:^

    Q 1 Reply Last reply
    2
    • sierdzioS sierdzio

      You need to use OpenSSL in your project - link OpenSSL libs with your application and it should start working.

      Some docs:

      • https://doc.qt.io/qt-5.12/ssl.html
      • https://doc.qt.io/qt-5/android-openssl-support.html
      Q Offline
      Q Offline
      qcoderpro
      wrote on last edited by
      #3

      @sierdzio

      It says: By default, an SSL-enabled Qt library dynamically loads any installed OpenSSL library at run-time

      I'm on Windows.

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #4

        Yes, well there isn't any installed OpenSSL library on Windows :D

        (Z(:^

        Q 1 Reply Last reply
        0
        • sierdzioS sierdzio

          Yes, well there isn't any installed OpenSSL library on Windows :D

          Q Offline
          Q Offline
          qcoderpro
          wrote on last edited by qcoderpro
          #5

          @sierdzio

          But I've installed OpenSSL using Qt!
          You mean I can't load an image from the Internet on Windows!?

          This guy is running that project on Windows successfully!

          sierdzioS 1 Reply Last reply
          0
          • Q qcoderpro

            @sierdzio

            But I've installed OpenSSL using Qt!
            You mean I can't load an image from the Internet on Windows!?

            This guy is running that project on Windows successfully!

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #6

            @qcoderpro said in QML Image: TLS initialization failed:

            @sierdzio

            But I've installed OpenSSL using Qt!

            But it's not a system-wide installation.

            You mean I can't load an image from the Internet on Windows!?

            You can. Just link OpenSSL to your project, or place OpenSSL DLLs close to the .exe.

            (Z(:^

            Q 1 Reply Last reply
            0
            • sierdzioS sierdzio

              @qcoderpro said in QML Image: TLS initialization failed:

              @sierdzio

              But I've installed OpenSSL using Qt!

              But it's not a system-wide installation.

              You mean I can't load an image from the Internet on Windows!?

              You can. Just link OpenSSL to your project, or place OpenSSL DLLs close to the .exe.

              Q Offline
              Q Offline
              qcoderpro
              wrote on last edited by
              #7

              @sierdzio

              Just link OpenSSL to your project

              How to do that on Windows?

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #8
                • find where your OpenSSL installation is
                • in your .pro file (I assume you're using qmake), add:
                LIBS+=path/to/openssl/libs
                INCLUDEPATH+=path/to/openssl/include
                

                (Z(:^

                Q 1 Reply Last reply
                1
                • sierdzioS sierdzio
                  • find where your OpenSSL installation is
                  • in your .pro file (I assume you're using qmake), add:
                  LIBS+=path/to/openssl/libs
                  INCLUDEPATH+=path/to/openssl/include
                  
                  Q Offline
                  Q Offline
                  qcoderpro
                  wrote on last edited by qcoderpro
                  #9

                  @sierdzio

                  I've installed both x64 and x86 versions of openssl but the kit I'm using to run the project is x64 so I add: C:\Qt\Tools\OpenSSL\Win_x64\lib

                  But I'm using CMake. Can I add these two lines just like the .pro file of qmake in it?

                  LIBS += C:\Qt\Tools\OpenSSL\Win_x64\lib   // (There's no 'libs' folder in the openssl directory)
                  INCLUDEPATH += C:\Qt\Tools\OpenSSL\Win_x64\include
                  
                  1 Reply Last reply
                  0
                  • sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #10

                    For cmake, you should use FindOpenSSL: https://cmake.org/cmake/help/latest/module/FindOpenSSL.html

                    (Z(:^

                    Q 1 Reply Last reply
                    3
                    • sierdzioS sierdzio

                      For cmake, you should use FindOpenSSL: https://cmake.org/cmake/help/latest/module/FindOpenSSL.html

                      Q Offline
                      Q Offline
                      qcoderpro
                      wrote on last edited by qcoderpro
                      #11

                      @sierdzio

                      I added the following two lines in the .txt file and saved the project. No errors came up:

                      find_package(OpenSSL)
                      target_link_libraries(QML_5 PRIVATE OpenSSL::SSL)
                      

                      But still the project can't run successfully!

                      12f0f584-a4de-4aa9-8ffd-59e368f3b1de-image.png

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

                        Hi,

                        Which version of OpenSSL are you using ?

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

                        Q 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          Hi,

                          Which version of OpenSSL are you using ?

                          Q Offline
                          Q Offline
                          qcoderpro
                          wrote on last edited by
                          #13

                          @SGaist

                          I don't know! (How to know that!?)

                          But it's written in CMakeLists.txt:

                          cmake_minimum_required(VERSION 3.14)

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

                            That's the minimal cmake version required to build the project.

                            As for OpenSSL, the installer might tell you this.
                            The headers of the library.

                            Or use QSslSocket::sslLibraryVersionString.

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

                            Q 1 Reply Last reply
                            0
                            • SGaistS SGaist

                              That's the minimal cmake version required to build the project.

                              As for OpenSSL, the installer might tell you this.
                              The headers of the library.

                              Or use QSslSocket::sslLibraryVersionString.

                              Q Offline
                              Q Offline
                              qcoderpro
                              wrote on last edited by
                              #15

                              @SGaist

                              As for OpenSSL, the installer might tell you this.
                              The headers of the library.

                              Capture4.PNG

                              Or use QSslSocket::sslLibraryVersionString.

                              How to use it in my QML project?
                              I used it this way but that doesn't work!

                              Component.onCompleted: {
                                      console.log(QSslSocket::sslLibraryVersionString)
                                  }
                              
                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                @qcoderpro said in QML Image: TLS initialization failed:

                                QSslSocket::sslLibraryVersionString

                                Use it in you main.cpp.

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

                                Q 1 Reply Last reply
                                1
                                • SGaistS SGaist

                                  @qcoderpro said in QML Image: TLS initialization failed:

                                  QSslSocket::sslLibraryVersionString

                                  Use it in you main.cpp.

                                  Q Offline
                                  Q Offline
                                  qcoderpro
                                  wrote on last edited by qcoderpro
                                  #17

                                  @SGaist

                                  I included these two header files:

                                  #include <iostream>
                                  #include <QSslSocket>
                                  

                                  and this line in main.cpp:

                                  std::cout<< "The openSSL version is: " <<
                                              QSslSocket::sslLibraryVersionString << '\n'
                                  

                                  In return I get this warning in the Issues window and nothing related to what I foresee in Application/Compile Output windows!

                                  warning: address of function 'QSslSocket::sslLibraryVersionString' will always evaluate to 'true'

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

                                    QSslSocket::sslLibraryVersionString is a static function that you have to call.

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

                                    Q 1 Reply Last reply
                                    1
                                    • SGaistS SGaist

                                      QSslSocket::sslLibraryVersionString is a static function that you have to call.

                                      Q Offline
                                      Q Offline
                                      qcoderpro
                                      wrote on last edited by
                                      #19

                                      @SGaist

                                      Yes, I didn't notice the parentheses enough. Finally using: qInfo() << QSslSocket::sslLibraryVersionString(); I could see the result: "OpenSSL 1.1.1f 31 Mar 2020", which is very close to what the installer showed!

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

                                        Except it should be the j release. You should ensure that this is the one used by your application.

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

                                        Q 1 Reply Last reply
                                        0
                                        • SGaistS SGaist

                                          Except it should be the j release. You should ensure that this is the one used by your application.

                                          Q Offline
                                          Q Offline
                                          qcoderpro
                                          wrote on last edited by qcoderpro
                                          #21

                                          @SGaist

                                          You mean I have two files/packs installed as openSSL, one with f release and the other with j and that f release is what QtCreator is using!? So what is the problem with that f release the IDE is using and why can't it run the program by that properly?

                                          Or probably there's a conflict between the two releases and I need to uninstall one to run the app properly! :(
                                          But how?

                                          Q 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