Unable to access Ssl error list from QNetworkAccessManager

Go To StackoverFlow.com

1

I'm working on a project where I'm trying to send request to our webservice via REST requests. First I only connected the finished(QNetworkReply*) signal to a slot but since it never finished possible due to ssl issues I aslo tried to connect the sslErrors(QNetworkReply*, const QList<QSslError>&) slot as well since the request is https.

connect(&_accessManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), 
        this, SLOT(printSslErrors(QNetworkReply*, const QList<QSslError>&)));

Then in my print function I'm not able to access the error list in any way.

void AssetManager::printSslErrors(QNetworkReply *reply, const QList<QSslError>& errors) {
     ...
}

I'v tried:

const QSslError test = errors.at(0); // error on 'test' 
QSslError test = errors.at(0); // error on 'test'

or

foreach(QSslError error, errors) {
    qDebug() << error.errorString(); // error on 'errors'
}
for(int i = 0; i < errors.count(); i++) {
     qDebug() << errors.at(i).errorString(); // error on 'errors'
}

which results in:

error C2079: 'test' uses undefined class 'QSslError'
error C2440: 'initializing' : cannot convert from 'const QSslError' to 'int'

or

error C2027: use of undefined type 'QSslError'
error C2228: left of '.toString' must have class/struct/union

also, that IntelliSense underlines errors or test with the message:

IntelliSense: incomplete type is not allowed

(Notice that it doesnt complain when I do errors.count())

I include <QSslError> in the headerfile...

I've been struggeling quite a lot with the sslError signal and a few weeks ago I was not even able to connect the signal to anything since it "doesn't exists". I'm I missing a module or something?

Thanks for your help

Edit:

Still getting the error:

Object::connect: No such signal QNetworkAccessManager::sslErrors(QNetworkReply*, const QList&)

Also, cannot check if I have Ssl

qDebug() << QSslSocket::supportsSsl();

Since QSslSocket is undefined even though it's included. It must something major that im missing here right? Do I have to install something? I am completly lost here :(

2012-04-04 03:03
by chikuba


5

Make sure your Qt is built with SSL support turned on (and that OpenSSL dlls can be found on the PATH).

This is usually only a problem if you built Qt yourself (I often keep forgetting those config options too), or if you are using Qt from linux distribution that happened to build it without SSL (although I've never seen that).

EDIT: If you need to build it on windows (and can't use prebuilt binaries for some reason):

  • Download and unpack OpenSSL and Qt into the same folder. For example:

    c:\root\openssl-1.0.1

    c:\root\qt-everywhere-opensource-src-4.8.1

  • Launch Visual Studio command line and run c:\root\openssl-1.0.1\ms\32all.bat, wait for things to build

  • cd into c:\root\qt-everywhere-opensource-src-4.8.1 and run

    configure.exe -platform win32-msvc2010 -openssl -I c:\root\openssl-1.0.1\include

  • make sure Qt detected and enabled OpenSSL support (configure prints out the list of everything)

  • run nmake to build Qt itself

(modify appropriately for other versions of VS)

2012-04-04 05:27
by Eugene
do you know how to build it for windows? seen so many guides and they are all different .. - chikuba 2012-04-10 03:13


0

I just had the same error and wondered why the signal was not valid. As indicated above, it is indeed since OpenSSL support is not enabled. See QNetworkAccessManager.h:144:146:

#ifndef QT_NO_OPENSSL
    void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
#endif

i.e. the signal is only declared if OpenSSL support was in place when Qt was compiled.

2012-06-18 16:42
by darrenp
Ads