Skip to content

Commit 1dce152

Browse files
author
jef
committedMay 9, 2010
handle ssl errors
git-svn-id: http://svn.osgeo.org/qgis/trunk@13448 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 4ab3c74 commit 1dce152

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6528,6 +6528,9 @@ void QgisApp::namSetup()
65286528

65296529
connect( nam, SIGNAL( proxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ),
65306530
this, SLOT( namProxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ) );
6531+
6532+
connect( nam, SIGNAL( sslErrors( QNetworkReply *, const QList<QSslError> & ) ),
6533+
this, SLOT( namSslErrors( QNetworkReply *, const QList<QSslError> & ) ) );
65316534
}
65326535

65336536
void QgisApp::namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *auth )
@@ -6562,6 +6565,31 @@ void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthe
65626565
auth->setPassword( password );
65636566
}
65646567

6568+
void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors )
6569+
{
6570+
QString msg = tr( "SSL errors occured accessing URL %1:" ).arg( reply->request().url().toString() );
6571+
bool otherError = false;
6572+
6573+
foreach( QSslError error, errors )
6574+
{
6575+
if ( error.error() != QSslError::SelfSignedCertificate &&
6576+
error.error() != QSslError::HostNameMismatch )
6577+
otherError = true;
6578+
msg += "\n" + error.errorString();
6579+
}
6580+
6581+
msg += tr( "\n\nIgnore errors?" );
6582+
6583+
if ( !otherError ||
6584+
QMessageBox::warning( this,
6585+
tr( "SSL errors occured" ),
6586+
msg,
6587+
QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Ok )
6588+
{
6589+
reply->ignoreSslErrors();
6590+
}
6591+
}
6592+
65656593
void QgisApp::namUpdate()
65666594
{
65676595
QNetworkProxy proxy;

‎src/app/qgisapp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class QgsGPSInformationWidget;
7474
#include <QToolBar>
7575
#include <QAbstractSocket>
7676
#include <QPointer>
77+
#include <QSslError>
7778

7879
#include "qgsconfig.h"
7980
#include "qgsfeature.h"
@@ -403,6 +404,7 @@ class QgisApp : public QMainWindow
403404
//! request credentials for network manager
404405
void namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *auth );
405406
void namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthenticator *auth );
407+
void namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors );
406408

407409
protected:
408410

0 commit comments

Comments
 (0)
Please sign in to comment.