[auth] Clear network authentication cache on SSL errors

This commit is contained in:
Alessandro Pasotti 2017-10-23 16:02:18 +02:00
parent a48c2e8fd4
commit cde36f3247
2 changed files with 38 additions and 11 deletions

View File

@ -25,6 +25,7 @@
#include <QToolButton>
#include "qgsauthmanager.h"
#include "qgsnetworkaccessmanager.h"
#include "qgsauthcertutils.h"
#include "qgsauthtrustedcasdialog.h"
#include "qgscollapsiblegroupbox.h"
@ -55,6 +56,11 @@ QgsAuthSslErrorsDialog::QgsAuthSslErrorsDialog( QNetworkReply *reply,
}
setupUi( this );
cbClearAuthCacheOnErrors->setChecked( QgsSettings().value( QStringLiteral( "clear_auth_cache_on_errors" ), false, QgsSettings::Section::Auth ).toBool( ) );
connect( cbClearAuthCacheOnErrors, &QCheckBox::clicked, this, [ ]( bool checked )
{
QgsSettings().setValue( QStringLiteral( "clear_auth_cache_on_errors" ), checked, QgsSettings::Section::Auth );
} );
connect( buttonBox, &QDialogButtonBox::clicked, this, &QgsAuthSslErrorsDialog::buttonBox_clicked );
connect( btnChainInfo, &QToolButton::clicked, this, &QgsAuthSslErrorsDialog::btnChainInfo_clicked );
connect( btnChainCAs, &QToolButton::clicked, this, &QgsAuthSslErrorsDialog::btnChainCAs_clicked );
@ -188,6 +194,13 @@ void QgsAuthSslErrorsDialog::buttonBox_clicked( QAbstractButton *button )
reject();
break;
}
// Clear access cache
if ( QgsSettings().value( QStringLiteral( "clear_auth_cache_on_errors" ),
false,
QgsSettings::Section::Auth ).toBool( ) )
{
QgsNetworkAccessManager::instance()->clearAccessCache();
}
}
void QgsAuthSslErrorsDialog::populateErrorsList()

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>617</width>
<height>710</height>
<width>568</width>
<height>550</height>
</rect>
</property>
<property name="windowTitle">
@ -169,7 +169,7 @@
</sizepolicy>
</property>
<property name="title">
<string>Save SSL server exception</string>
<string>Save SSL server e&amp;xception</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -219,14 +219,28 @@
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Ignore|QDialogButtonBox::Save</set>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="cbClearAuthCacheOnErrors">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The authentication cache stores all connections even when the connection fails. &lt;/p&gt;&lt;p&gt;If you make any change to the authentication configuration or to the CAs you should clear the authentication cache or restart QGIS. &lt;/p&gt;&lt;p&gt;&lt;br/&gt;When this option is checked, it will clear the authentication cache when this dialog is closed.&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Clear authentication cache</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Abort|QDialogButtonBox::Ignore|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>