21 #include <QDialogButtonBox> 23 #include <QPushButton> 25 #include <QToolButton> 40 , mSslConfiguration( reply->sslConfiguration() )
41 , mSslErrors( sslErrors )
43 , mHostPort( hostport )
59 lblWarningIcon->setPixmap( style->
standardIcon( QStyle::SP_MessageBoxWarning ).
pixmap( 48, 48 ) );
60 lblWarningIcon->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
62 lblErrorsText->setStyleSheet(
"QLabel{ font-weight: bold; }" );
72 saveButton()->
setText(
QString(
"%1 && %2" ).arg( saveButton()->text(),
73 ignoreButton()->text() ) );
75 grpbxSslConfig->setChecked(
false );
76 grpbxSslConfig->setCollapsed(
true );
77 connect( grpbxSslConfig, SIGNAL( toggled(
bool ) ),
78 this, SLOT( loadUnloadCertificate(
bool ) ) );
80 connect( wdgtSslConfig, SIGNAL( readyToSaveChanged(
bool ) ),
81 this, SLOT( widgetReadyToSaveChanged(
bool ) ) );
82 wdgtSslConfig->setConfigCheckable(
false );
83 wdgtSslConfig->certificateGroupBox()->setFlat(
true );
87 btnChainInfo->setVisible(
false );
88 btnChainCAs->setVisible(
false );
89 grpbxSslConfig->setVisible(
false );
100 void QgsAuthSslErrorsDialog::loadUnloadCertificate(
bool load )
102 grpbxSslErrors->setCollapsed( load );
105 QgsDebugMsg(
"Unloading certificate and host:port" );
106 clearCertificateConfig();
109 wdgtSslConfig->setEnabled(
true );
111 wdgtSslConfig->setSslCertificate( mSslConfiguration.
peerCertificate(), mHostPort );
114 wdgtSslConfig->appendSslIgnoreErrors( mSslErrors );
118 void QgsAuthSslErrorsDialog::showCertificateChainInfo()
122 if ( !peerchain.isEmpty() )
136 void QgsAuthSslErrorsDialog::showCertificateChainCAsInfo()
145 void QgsAuthSslErrorsDialog::widgetReadyToSaveChanged(
bool cansave )
153 void QgsAuthSslErrorsDialog::checkCanSave()
155 widgetReadyToSaveChanged( wdgtSslConfig->readyToSave() );
158 void QgsAuthSslErrorsDialog::clearCertificateConfig()
160 wdgtSslConfig->resetSslCertConfig();
161 wdgtSslConfig->setEnabled(
false );
165 void QgsAuthSslErrorsDialog::on_buttonBox_clicked(
QAbstractButton *button )
167 QDialogButtonBox::StandardButton btnenum( buttonBox->standardButton( button ) );
170 case QDialogButtonBox::Ignore:
172 QString(
"%1:%2" ).arg( mDigest, mHostPort ),
176 case QDialogButtonBox::Save:
178 wdgtSslConfig->saveSslCertConfig();
181 case QDialogButtonBox::Abort:
188 void QgsAuthSslErrorsDialog::populateErrorsList()
192 Q_FOREACH (
const QSslError &err, mSslErrors )
198 teSslErrors->setPlainText( errs.
join(
"\n" ) );
201 QPushButton *QgsAuthSslErrorsDialog::ignoreButton()
203 return buttonBox->button( QDialogButtonBox::Ignore );
208 return buttonBox->button( QDialogButtonBox::Save );
213 return buttonBox->button( QDialogButtonBox::Abort );
216 void QgsAuthSslErrorsDialog::on_btnChainInfo_clicked()
218 showCertificateChainInfo();
221 void QgsAuthSslErrorsDialog::on_btnChainCAs_clicked()
223 showCertificateChainCAsInfo();
226 void QgsAuthSslErrorsDialog::on_grpbxSslErrors_collapsedStateChanged(
bool collapsed )
230 btnChainInfo->setVisible(
false );
231 btnChainCAs->setVisible(
false );
static QgsAuthManager * instance()
Enforce singleton pattern.
static QString sslErrorEnumString(QSslError::SslError errenum)
Get short strings describing an SSL error.
QNetworkRequest request() const
QString join(const QString &separator) const
QString toString(QFlags< QUrl::FormattingOption > options) const
QSslCertificate peerCertificate() const
QPixmap pixmap(const QSize &size, Mode mode, State state) const
QList< QSslCertificate > peerCertificateChain() const
Dialog wrapper for widget displaying detailed info on a certificate and its hierarchical trust chain...
~QgsAuthSslErrorsDialog()
QString errorString() const
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
static QString shaHexForCert(const QSslCertificate &cert, bool formatted=false)
Get the sha1 hash for certificate.
bool updateIgnoredSslErrorsCache(const QString &shahostport, const QList< QSslError > &errors)
Update ignored SSL error cache with possible ignored SSL errors, using sha:host:port key...
QgsAuthSslErrorsDialog(QNetworkReply *reply, const QList< QSslError > &sslErrors, QWidget *parent=nullptr, const QString &digest=QString(), const QString &hostport=QString())
Construct a dialog to handle SSL errors and saving SSL server certificate exceptions.
void setText(const QString &text)
Widget for listing trusted Certificate (Intermediate) Authorities used in secure connections.
QList< QSslCertificate > caCertificates() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const