My goal is to get the source code (or images) from a webpage over a SSL connection using QNetworkRequest
with the QNetworkAccessManager
.
OpenSSL 1.1.0 doesn't work with Qt 5.8! Look in Edit 2 for the install solution!
First Try: Get the ssleay32.lib and the libeay32.lib and copy them into the debug and the release folder. Dont work.
Second Try: (deleted because it's nonsense) But it doesnt work again.
Code (works fine for normal http):
QUrl url = QUrl(name);
data.clear();
QNetworkRequest *request = new QNetworkRequest(url);
request->setRawHeader("User-Agent", userAgent);
QSslConfiguration sslConfiguration(QSslConfiguration::defaultConfiguration());
request->setSslConfiguration(sslConfiguration);
reply = webCtrl->get(*request);
connect(webCtrl, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
connect(reply, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
connect(reply, SIGNAL(finished()), this, SLOT(onReplyFinished()));
Error Messages:
qt.network.ssl: QSslSocket: cannot call unresolved function d2i_DHparams
qt.network.ssl: QSslSocket: cannot call unresolved function DH_free
qt.network.ssl: QSslSocket: cannot call unresolved function d2i_DHparams
qt.network.ssl: QSslSocket: cannot call unresolved function DH_free
qt.network.ssl: QSslSocket: cannot call unresolved function d2i_DHparams
qt.network.ssl: QSslSocket: cannot call unresolved function DH_free
qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_new
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_library_init
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
Error creating SSL context ()
Edit 1:
I found this Artikel and OpenSSL 1.1.0 will be working with Qt 5.10 but not in Qt 5.8 what I am using.
And in this Artikel I found the QSslSocket::sslLibraryBuildVersionString()
command and I Need OpenSSL Version: OpenSSL 1.0.2h 3 May 2016
.
I will checkout the other OpenSSL Version later and edit this post if it is working or not.
Edit 2:
Download OpenSSL 1.0.2h 3 May 2016
and Install 7zip and Perl. Extract the openSSL folder and follow INSTALL.W64
. Go to the bin
folder and copy libeay32-xxx.dll
and ssleay32-xxx.dll
to the application folder and rename the files to libeay32.dll
and ssleay32.dll
. Thanks @[Max Go].
Now the SSL connection finaly works, but I get an error message when I Close the application and the web connection was used at runtime.
Exception at 0x000000007772D1CB (ntdll.dll) in onlineTest.exe: 0xC0000005: Access Violation reading position 0x0000000000000074.
VS2015 Debug Window "mem.c" line 443:
free_debug_func 0x0000000000000000 void(*)(void *, int)
free_func 0x000007fee778b1ba {libeay32.dll!free} void(*)(void *)
str 0x0000000002500cf0 void *
Edit 3: I forgot to compile the -d debug .dll's. Simply change the compiler mode to Debug, generate the Debug .dll's, rename if needed without the -d and then copy the debug .dll's into the debug folder and the normal .dll's into the release folder.