Petr
Petr

Reputation: 14455

how can I enable SSL in QT windows application?

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.

Upvotes: 8

Views: 25190

Answers (3)

convexbytes
convexbytes

Reputation: 182

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.

Upvotes: 2

Petr
Petr

Reputation: 14455

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.

Upvotes: 18

Dasun
Dasun

Reputation: 3294

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
}

Upvotes: 9

Related Questions