Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing SSL errors

Tags:

c++

qt

qtwebkit

I want to be able to read the headers sent back from a webpage in SSL mode. My Qt app however can't reach the webpage because it's in SSL mode I am gathering? Normal webview browsing in SSL is possible in my app using this connect:

connect(view->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> & )),
                        this, SLOT(onSslErrors(QNetworkReply*, const QList<QSslError> & )));

This suppresses the SSL errors in the webview but I have a separate function which get's the headers using this method:

//Send a request to validate URL
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkRequest request;
request.setUrl(QUrl(text));
request.setRawHeader("User-Agent", "MyApp1.0");
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
                  QNetworkReply *reply = manager->get(request);
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();

qDebug() << "QLoop: " << reply->rawHeader("My-Application");
  if(reply->rawHeader("My-Application") == "1"){
      appUrl = text;
  }

I need this method because I set a config file with our webapps URL in it before the the app will connect to it using webview->load(QURL(appUrl )). Just not sure how to supress/handle SSL errors using QNetworkAccessManager?

like image 695
Kal Avatar asked Jan 11 '13 11:01

Kal


1 Answers

You need to connect your QNAM objects signal sslErrors(QNetworkReply *, QList<QSslError>) to a slot where you set QNetworkReply::ignoreSslErrors() and that'll allow QNAM to continue running. Qt Docs on it.

like image 79
Nicholas Smith Avatar answered Nov 05 '22 06:11

Nicholas Smith