Build a cache of allowed SSL exceptions and use them on future network requests

The   class  NetworkAccessManager   sub-classes  QNetworkAccessManager
adding  a  message  box  to  ask   the  user  if  SSL  errors  may  be
ignored. Ignored errors  are ignored in future server  replies so that
the user is not asked about he same peer certificate chain repeatedly.
The cache is currently per process only and not persistent.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7361 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville
2016-12-04 14:17:01 +00:00
parent 55811efd64
commit bae3b94fd6
4 changed files with 73 additions and 27 deletions
+1 -20
View File
@@ -8,8 +8,6 @@
#include <QDateTime>
#include <QApplication>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QRegularExpression>
#include <QObject>
#include <QSettings>
@@ -316,25 +314,8 @@ int main(int argc, char *argv[])
).toBool () ? 1u : 4u;
}
QNetworkAccessManager network_manager {&a};
// run the application UI
MainWindow w(temp_dir, multiple, &multi_settings, &mem_jt9, downSampleFactor, &network_manager, &splash);
// set up handling for any SSL issues
QObject::connect (&network_manager, &QNetworkAccessManager::sslErrors, [&w] (QNetworkReply * reply, QList<QSslError> const& errors) {
QString message;
for (auto const& error: errors)
{
message += '\n' + reply->request ().url ().toDisplayString () + ": "
+ error.errorString ();
}
if (QMessageBox::Ignore == QMessageBox::question (&w, "Network SSL Errors", message, QMessageBox::Abort | QMessageBox::Ignore))
{
reply->ignoreSslErrors ();
}
});
MainWindow w(temp_dir, multiple, &multi_settings, &mem_jt9, downSampleFactor, &splash);
w.show();
splash.raise ();
QObject::connect (&a, SIGNAL (lastWindowClosed()), &a, SLOT (quit()));