how can I enable SSL in QT windows application?

20,537

Solution 1

So after long time I figured what the problem is:

These 2 libraries need to be in same folder as your executable OR in windows system folder (system32 I think):

libeay32.dll
ssleay32.dll

You will find them in \bin of your OpenSSL folder, since I copied these 2 libs there it works

IMPORTANT: When deploying to client computers, it's also necessary to install vcredist package that was used to compile these .dll which may differ from vcredist package needed to run the application itself. vcredist version depends on version of the libraries.

Solution 2

You have to add OpenSSL lib in your project. In windows Qt doesn't come with OpenSSL lib. (I think it's a legal issue). You can find OpenSSL developer libs in URI you posted. If you are compiling against 32bit framework, what you need to download is Win32 OpenSSL v1.0.1e

This is what I have in my project.

QT += core gui network
win32{
    LIBS += -LC:/OpenSSL-Win32/lib -lubsec
    INCLUDEPATH += C:/OpenSSL-Win32/include
}

Solution 3

As you figured out already, you were missing dlls. Here is more information

Check what version of ssl you need with

QSslSocket::sslLibraryBuildVersionString();

For ssl 1.0.x (qt<5.12.4) you are likely missing libeay32.dll and ssleay32.dll.

For ssl 1.1.x (qt>=5.12.4) binary compatibility broke (qt 5.12.4 released), so you might need libssl-1_1.dll and libcrypto-1_1.dll, and its dependencies capi.dll and dasync.dll.

Share:
20,537
Petr
Author by

Petr

Updated on August 21, 2020

Comments

  • Petr
    Petr over 3 years

    Qt requires open ssl libraries to be installed on system. In debian / ubuntu when I install open ssl using apt everything works. But when I compile my application in windows, SSL features are not available I can verify this by executing

    QSslSocket::supportsSsl()
    

    How do I make it work in windows? I downloaded and installed open ssl from http://www.slproweb.com/products/Win32OpenSSL.html but it still returns false.