Skip to content
Permalink
Browse files
handle ssl errors
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13448 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 9, 2010
1 parent cfd52d0 commit 5d38bf38afc5642e7b827101215f315b11f92ee4
Showing with 30 additions and 0 deletions.
  1. +28 −0 src/app/qgisapp.cpp
  2. +2 −0 src/app/qgisapp.h
@@ -6528,6 +6528,9 @@ void QgisApp::namSetup()

connect( nam, SIGNAL( proxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ),
this, SLOT( namProxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ) );

connect( nam, SIGNAL( sslErrors( QNetworkReply *, const QList<QSslError> & ) ),
this, SLOT( namSslErrors( QNetworkReply *, const QList<QSslError> & ) ) );
}

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

void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors )
{
QString msg = tr( "SSL errors occured accessing URL %1:" ).arg( reply->request().url().toString() );
bool otherError = false;

foreach( QSslError error, errors )
{
if ( error.error() != QSslError::SelfSignedCertificate &&
error.error() != QSslError::HostNameMismatch )
otherError = true;
msg += "\n" + error.errorString();
}

msg += tr( "\n\nIgnore errors?" );

if ( !otherError ||
QMessageBox::warning( this,
tr( "SSL errors occured" ),
msg,
QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Ok )
{
reply->ignoreSslErrors();
}
}

void QgisApp::namUpdate()
{
QNetworkProxy proxy;
@@ -74,6 +74,7 @@ class QgsGPSInformationWidget;
#include <QToolBar>
#include <QAbstractSocket>
#include <QPointer>
#include <QSslError>

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

protected:

0 comments on commit 5d38bf3

Please sign in to comment.