Example for QNetworkAccessManager with SSL
Hi,
I would like to upgrade my network request to SSL but was not able to find an example on the web how to do this properly. Here is the code I currently have:
Code:
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
manager->get(QNetworkRequest(url)); // url = http://xyz...
I changed it to this:
Code:
QSslConfiguration sslConfiguration(QSslConfiguration::defaultConfiguration());
sslConfiguration.setProtocol(QSsl::TlsV1_2);
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
manager->get(QNetworkRequest(url)); // url = https://xyz...
The second part is still working, which is really surprising since I use a self-signed ssl certificate. So I am guessing I am doing something wrong here. Can someone help?
Thanks!
Re: Example for QNetworkAccessManager with SSL
I don't really know what You've done but when I used SSL I did it this way (and it worked):
Code:
QNetworkRequest request();
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
and in application directory I put these files (these are OpenSSL library files):
libeay32.dll
ssleay32.dll
from: http://www.npcglib.org/~stathis/blog...piled-openssl/
btw. I think that You just did nothing in this code:
Code:
QSslConfiguration sslConfiguration(QSslConfiguration::defaultConfiguration());
sslConfiguration.setProtocol(QSsl::TlsV1_2);
because You created object that is not used anywhere.