I create some https requests directly from my CPML views, for example, for image sources as I have a The certificate is server-side, I need to tell Qt to ignore some SSL errors (I control both server and client applications, so it should not really be a problem).
I have created a QQmlNetworkAccessManagerFactory to create Nams, where I connect to the sslErrors signal
UltraQmlAccessManagerFactory.h:.
#ifndef FACKFACKTORy_H #define FACKFACKTORy_H #include & lt; QQmlNetworkAccessManagerFactory & gt; # Include & lt; QObject & gt; # Include & lt; QNetworkReply & gt; # Include & lt; QList & gt; # Include & lt; QSslError & gt; # Include & lt; QNetworkAccessManager & gt; # Include & lt; QDebug & gt; # Include & lt; QSslCertificate & gt; Category UltraQmlNetworkAccessManagerFactory: Public QObject, Public QQmlNetworkAccessManagerFactory {Q_OBJECT PERSONAL: QNetworkAccessManager * name; QList & LT; QSslError & gt; ExpectedSslErrors; Public: Clear UltraQmlNetworkAccessManagerFactory (); ~ UltraQmlNetworkAccessManagerFactory (); Create virtual QNetworkAccessManager * (QObject * parent); Public Slots: Unknown SSLR (QNetworkReply * Answer, QList & lt; QSslError & gt; Errors) at zero; }; UltraQmlNetworkAccessManagerFactory.cpp: #include :: ~ UltraQmlNetworkAccessManagerFactory () {Cancel Undelete; } QNetworkAccessManager * UltraQmlNetworkAccessManagerFactory :: Creation (QObject * Parents) {QNetworkAccessManager * nam = New QNetworkAccessManager (parent); QObject :: connect (nam, sslErrors (QNetworkReply *, QList & lt; QSslError & gt;)), this, slot (onIgnoreSslErrors (QNetworkReply *, QList & lt; QSslError & gt;))); Return name; } Zero UltraQmlNetworkAccessManagerFactory :: onIgnoreSslErrors (QNetworkReply * Responses, QList & lt; QSslError & gt; Errors) {for (int i = 0; I & lt; errors.size (); i ++) {qDebug () & lt ; & Lt; "E:" & lt; & Lt; Errors.at (i) & lt; & Lt; Endl; } Answer-> Undiscovered SSLLR (errors); } There is also some glue in main.cpp that this factory is used, I suspect that this part is a source of errors because qDebug printers are visible in the output. . As can be seen in the .cpp file in IgnoreSslErrors on the Function / Slot, I try to get every error (in the form of a test), but I do not get expected results in output .
Output E: "The certificate is self-signed and unreliable" QRC: /qml/file/ImageView.qml: 16: 5: QML Image: SSL handshake failed
I successfully specified QNetworkRequests
from C ++ directly QSslConfiguration
, by specifying TLSV1_0 and a certificate Have given. As I suspect that interference fails because on the one hand SSL and other TLS are expected I QNsquoConfiguration on QNetworkRequest
object through answer-> Gt; request ();
This, however, does not change anything.
No comments:
Post a Comment