Pavel DorofeevMay 29, 2022, 9:28 p.m.

Как реализовать TLSv1.2 на Qt 4.8.1

Initially, QSsl in Qt 4.8.1 (released about 13 years ago) used only the maximum of TLS v1.0.

Today is 2022 and Tls v1.0 and v1.1 are being blocked by almost every decent site on the internet.

Qt in QSsl uses the open library openssl.

TLS v1.2 appears in openssl version 1.0.2.

Building the openssl 1.0.2 libraries is not a problem both dynamically and statically (ssleay32.dll/lib, libeay32.dll/lib).

But how to use them in Qt 4.8.1 so that the connection occurs via Tlsv1.2 is not a trivial task (at first glance).

What to do? You need to study the openssl source code to understand how Tls1.2 is called first.

And it turns out that everything is actually not difficult, since the openssl developers did not change the general logic of the sources. Just in the right place in the qsslsocket_openssl.cpp file, you need to create a context for connecting through the appropriate function variant:

switch (configuration.protocol) {
    case QSsl::SslV2:
        ctx = SSL_CTX_new(client ? SSLv2_client_method() : SSLv2_server_method());
        ctx = 0; // SSL 2 not supported by the system, but chosen deliberately -> error
    case QSsl::SslV3:

#ifndef OPENSSL_NO_SSL3 //++
        ctx = SSL_CTX_new(client ? SSLv3_client_method() : SSLv3_server_method());
        ctx = 0; // SSL 3 not supported by the system, but chosen deliberately -> error

    case QSsl::SecureProtocols: // SslV2 will be disabled below
    case QSsl::TlsV1SslV3: // SslV2 will be disabled below
    case QSsl::AnyProtocol:
        //--ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
        //--ctx = SSL_CTX_new(client ? SSLv23_client_method() : SSLv23_server_method());
        ctx = SSL_CTX_new(client ? TLSv1_2_client_method() : TLSv1_2_server_method());
        break; //++

    case QSsl::TlsV1:
        ctx = SSL_CTX_new(client ? TLSv1_client_method() : TLSv1_server_method());

In general, and all that is needed.

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.


Only authorized users can post comments.
Please, Log in or Sign up
Card image cap
Pulsum Via

Project for travelers from EVILEG.


Let me recommend you a great European Fornex hosting.

Fornex has proven itself to be a stable host over the years.

For Django projects I recommend VPS hosting

Following the link you will receive a 5% discount on shared hosting services, dedicated servers, VPS and VPN

View Hosting
Share on social networks

The EVILEG project has switched to a non-commercial basis and will develop solely on the enthusiasm of the site creator, the enthusiasm of users, donations and the hosting referral system

Thank you for your support

Available ways to support the project



C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10

C++ - Test 005. Structures and Classes

  • Result:83points,
  • Rating points4

C++ - Test 002. Constants

  • Result:58points,
  • Rating points-2
Last comments

Android and QML - Adding Splash Screen

Интересен формат иконки, если это png, то как решается проблема scalability? не растягивается ли лого на китайфонах с 1280х2500? У меня просто сплеш скрин с градиентом и логотипом, и вот несколь…

Qt/C++ - Lesson 023. Moving QGraphicsItem on QGraphicsScene with mouse help

FIGURE Abdominopelvic regions. Zjuaqd - Cialis Cialis Recommendations for preparing children and adolescents for invasive cardiac procedures a statement…

How to use nested forms in Django

Спасибо за полезную статью. Подскажите пожалуйста, что делать если нужно реализовать большее количество вложенных форм? Например если на модель Address ссылается fk другой модели, на котору…

Qt/C++ - Lesson 051. QMediaPlayer – simple audio player

Не думаю, QMediaPlayer в один поток проигрывает. Если вам нужно одновременное воспроизведение нескольких аудиоисточников, то вам нужна Bass audio library , насколько знаю, её обычно и…

Qt/C++ - Lesson 051. QMediaPlayer – simple audio player

есть такая вообще возможность ?
Now discuss on the forum

Sorting the added QML elements in the ListModel

I am writing an alarm clock in QML, I am required to sort the alarms in ascending order (depending on the date or time (if there are several alarms on the same day). I've done the sorting …

Изменение поведения QGroupBox при клике на его чекбокс

Я вынес виджеты вынес за пределы QGroupBox в итоге.

QSqlRelatipnalTabelModel Qt 4.8.1 как получить id внешней связи?

Есть еще принципиально другой вариант решить раз и навсегда вопрос с полей id внешней связи. Это форкнуть Qt 4.8.1 QSqlTableModel, то есть создать свою ветку развития. Например создадим кл…

Добавление AndroidManifest.xml в cmake

Добрый день. Как добавить AndroidManifest.xml в cmake? Это не работвет set(ANDROID_PACKAGE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/android CACHE INTERNAL "")set(ANDROID_BUID_DIR ${CMAKE_C…

Событие wheelEvent для виджета QLineEdit

вот что получилось: from PyQt5 import QtCore, QtGui, QtWidgets class LineEdit(QtWidgets.QLineEdit): def wheelEvent(self, event): #print("_") delta = 1 if e…
© EVILEG 2015-2022
Recommend hosting TIMEWEB