PDA

View Full Version : Server connection problem using OpenSSL with android



klaarx
22nd June 2017, 10:09
Hi everyone,

I'm developing for the first time a mobile application with Qt 5.8 based on a existing project.
I'm using a smartphone Samsung Galaxy S5 SM-G901F with Android 6.0.1 for debug.

I need to connect to a server with OpenSSL. I'm using OpenSSL 1.0.2k on Windows.
When I compile the project with MSVC2015 and Qt Creator, no connexion problem.
But when I compile this project for Android et execute on my smartphone, I can't connect (error : Diffie-Hellman parameters are not valid)

I've tried to compile OpenSSL to include .so files directly in the APK.
I've read the Qt tutorial http://doc.qt.io/qt-5/opensslsupport.html but it is for Qt 5.9 so I hope it's also a solution for Qt 5.8 but I'm not sure.
I've installed MSYS-1.0.11 and Perl 5.26 and tried to compile the OpenSSL 1.0.2h (compatible with Qt 5.8) source code.
Unfortunately, I'm stucked here :
12501


Did anyone try to compile these librairies ?
Is that the goodsolution to solve my problem ?
Is there any compatibility problem between the components I've installed ?

The previous programmer in charge of this project told me he had no problem to connect to the serveur with a HTC One. I didn't need to include the librairies in the APK
He borowed me this phone but I can't use it on my computer to test because it's not detected :/
The HTC One has Android 5.0.2 installed.
Is there a known issue with Android 6 ?

I need your help please
Thank you

Urthas
26th June 2017, 23:53
I haven't anything to offer in the way of a solution.

However, what I can do is confirm that I have the same problem (i.e., Diffie-Helman) on a Nexus 5 running Android 6.0.1, but no problem on a Nexus 7 running Android 5.1.

It looks like this might be an "out of scope" bug with Qt 5.8: https://bugreports.qt.io/browse/QTBUG-59321. I was hoping to avoid upgrading from 5.8 to 5.9 until my project is released but it would seem that upgrading is worth a shot after all.

klaarx
27th June 2017, 09:48
Thank you for your reply.
It's good to know I'm not the only one concerned by this issue.

I'm still trying to solve this problem. I'll let you know if I achieve to do it ;)

Urthas
27th June 2017, 17:46
Well, the good news is that after updating to 5.9, I no longer have any issues downloading files on either of the Android devices mentioned.

The bad news is that after updating to 5.9, downloading fails on my iOS device with the error: "SSL handshake failed".

update: Here is one solution for the now-broken iOS downloads:



QNetworkRequest request(url);
#if QT_VERSION == QT_VERSION_CHECK(5, 9, 0) && defined Q_OS_IOS
QSslConfiguration sslConf = request.sslConfiguration();
sslConf.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(sslConf);
#endif


(care of the discussion here: https://stackoverflow.com/questions/21636728/qt-ssl-handshake-failed)

Unrelated: for anyone updating to 5.9 (or from any version to any version, really), remember to review your UI. After updating to 5.9, my views look different (and not in a good way). >.<