Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
handle ssl errors
git-svn-id: http://svn.osgeo.org/qgis/trunk@13448 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 9, 2010
1 parent 4ab3c74 commit 1dce152
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -74,6 +74,7 @@ class QgsGPSInformationWidget;
#include <QToolBar>
#include <QAbstractSocket>
#include <QPointer>
#include <QSslError>

#include "qgsconfig.h"
#include "qgsfeature.h"
Expand Down Expand Up @@ -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:

Expand Down

0 comments on commit 1dce152

Please sign in to comment.