Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I enable SSL in QT windows application?

Tags:

c++

ssl

qt

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.

like image 271
Petr Avatar asked Dec 03 '13 12:12

Petr


People also ask

Does Qt use OpenSSL?

Qt binary installers include the OpenSSL libraries used by QtNetwork. However, those are not automatically deployed with applications that are built with Qt. Import and export restrictions apply for some types of software, and for some parts of the world.

What version of OpenGL does Qt use?

For Qt Quick 2 to work, a graphics driver that provides OpenGL 2.1 or higher is required. The default driver from Windows is OpenGL 1.1.

How do you use Windeployqt?

0 The simplest way to use windeployqt is to add the bin directory of your Qt installation (e.g. <QT_DIR\bin>) to the PATH variable and then run: windeployqt <path-to-app-binary> If ICU, etc. are not in the bin directory, they need to be in the PATH variable.


3 Answers

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.

like image 122
Petr Avatar answered Oct 05 '22 14:10

Petr


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
}
like image 29
Dasun Avatar answered Oct 05 '22 12:10

Dasun


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.

like image 45
convexbytes Avatar answered Oct 05 '22 12:10

convexbytes