Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt & SSL, Handshake failed

I have a problem. I've made a Qt application which is connecting to a https site. On my working machine, everything works fine. When I try to test my application on a clean Windows 7 machine, I observed the following issue:

After I have installed a fresh Win7 machine (installed all updates), after starting my application, I get a SSL Handshake failed error, SIGNAL(sslErrors(QNetworkReply*,QList)) is emitted with two empty error strings and error = QSslError::NoError. I was really searching the whole day why this happens, also could reproduce it with examples\network\securesocketclient\release\securesocketclient and domain "google.com".

Now, I found out, that once I have started the internet explorer accessing https://www.google.com, my application is also working as expected and no further handshake errors are coming.

BTW, it does not matter which site you are accessing - this is not related to google.com.

Can someone explain to me why this happens? Is it a bug in OpenSSL, or Qt, or both?

UPDATE

I found a way to live with that issue for myself, implementing the following ignore logic:

QSslError ignoreNOErrors(QSslError::NoError);

foreach(QSslError error, errors)
    if(error.error() != QSslError::NoError)
        qDebug() << error.errorString();

QList<QSslError> expectedSslErrors;
expectedSslErrors.append(ignoreNOErrors);
reply->ignoreSslErrors(expectedSslErrors);

Thanks

like image 686
inspector Avatar asked Feb 07 '14 20:02

inspector


People also ask

What is Qt for?

Qt is used for developing graphical user interfaces (GUIs) and multi-platform applications that run on all major desktop platforms and most mobile or embedded platforms. Most GUI programs created with Qt have a native-looking interface, in which case Qt is classified as a widget toolkit.

Why is Qt not popular?

The reason Qt isn't more popular in general is simply a steep learning curve. Historically, software engineers aren't known for their patience -- probably because their users aren't either -- and rarely have time to invest in learning an entire platform.

Is Qt framework or IDE?

Qt Creator is a cross-platform integrated development environment (IDE) built for the maximum developer experience. Qt Creator runs on Windows, Linux, and macOS desktop operating systems and allows developers to create software across desktop, mobile, and embedded platforms.

What is Qt for Python?

Qt for Python is the project that provides the official set of Python bindings (PySide6) that will supercharge your Python applications. While the Qt APIs are world renowned, there are more reasons why you should consider Qt for Python.


2 Answers

You could ignore certificate verify using QSslConfiguration::setPeerVerifyMode():

QSslConfiguration conf = request.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(conf);
like image 103
Libor B. Avatar answered Oct 19 '22 09:10

Libor B.


I was facing the same issue on Mac with Qt 5.5 and 5.6. When I upgraded to 5.7 it is solved. Hope it may help if you are still facing this issue.

like image 36
Mohammad Amir Avatar answered Oct 19 '22 09:10

Mohammad Amir