Results 1 to 2 of 2

Thread: Example for QNetworkAccessManager with SSL

  1. #1
    Join Date
    Apr 2014
    Posts
    116
    Thanks
    8
    Qt products
    Qt5
    Platforms
    MacOS X

    Default 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:
    Qt Code:
    1. manager = new QNetworkAccessManager(this);
    2. connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
    3. manager->get(QNetworkRequest(url)); // url = http://xyz...
    To copy to clipboard, switch view to plain text mode 

    I changed it to this:
    Qt Code:
    1. QSslConfiguration sslConfiguration(QSslConfiguration::defaultConfiguration());
    2. sslConfiguration.setProtocol(QSsl::TlsV1_2);
    3.  
    4. manager = new QNetworkAccessManager(this);
    5. connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
    6. manager->get(QNetworkRequest(url)); // url = https://xyz...
    To copy to clipboard, switch view to plain text mode 

    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!

  2. #2
    Join Date
    Sep 2011
    Posts
    86
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default 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):

    Qt Code:
    1. QNetworkRequest request();
    2. request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. QSslConfiguration sslConfiguration(QSslConfiguration::defaultConfiguration());
    2. sslConfiguration.setProtocol(QSsl::TlsV1_2);
    To copy to clipboard, switch view to plain text mode 
    because You created object that is not used anywhere.

Similar Threads

  1. Again QNetworkAccessManager POST and PHP
    By ZSWASW in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2014, 20:38
  2. QNetworkAccessManager put openssl
    By MCSpy in forum Qt Programming
    Replies: 2
    Last Post: 24th January 2014, 11:32
  3. How to use QNetworkAccessManager?
    By radmir in forum Newbie
    Replies: 1
    Last Post: 25th February 2013, 15:43
  4. QNetworkAccessManager
    By cuteatul in forum Qt Programming
    Replies: 1
    Last Post: 8th July 2011, 06:34
  5. Problems with QNetworkAccessManager
    By pfid in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2009, 20:51

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.