抑制SSL错误 [英] Suppressing SSL errors
问题描述
我想要能读取以SSL模式从网页传回的标头。我的Qt应用程序无法访问的网页,因为它是SSL模式我收集?在我的应用程序中使用此连接可以在SSL中正常浏览网页:
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> & )));
这抑制了webview中的SSL错误,但我有一个单独的函数, :
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;
}
我需要这个方法,因为我设置一个配置文件与我们的webapps URL应用程序将使用 webview-> load(QURL(appUrl))
连接到它。只是不知道如何使用QNetworkAccessManager来抑制/处理SSL错误。
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?
推荐答案
您需要连接QNAM对象信号 csslErrors(QNetworkReply *,QList< QSslError>)
到您设置 QNetworkReply :: ignoreSslErrors()
继续运行。 Qt文档。
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.
这篇关于抑制SSL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!