QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsauthsslconfigwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsauthsslconfigwidget.cpp
3  ---------------------
4  begin : May 17, 2015
5  copyright : (C) 2015 by Boundless Spatial, Inc. USA
6  author : Larry Shaffer
7  email : lshaffer at boundlessgeo dot com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgsauthsslconfigwidget.h"
18 #include "qgsauthcertificateinfo.h"
19 
20 #include <QDialogButtonBox>
21 #include <QPushButton>
22 #include <QSpinBox>
23 #include <QUrl>
24 
25 #include "qgsauthguiutils.h"
26 #include "qgsauthmanager.h"
27 #include "qgslogger.h"
28 #include "qgsapplication.h"
29 
30 
31 static void setItemBold_( QTreeWidgetItem *item )
32 {
33  item->setFirstColumnSpanned( true );
34  QFont secf( item->font( 0 ) );
35  secf.setBold( true );
36  item->setFont( 0, secf );
37 }
38 
39 static const QString configFoundText_() { return QObject::tr( "Configuration loaded from database" ); }
40 static const QString configNotFoundText_() { return QObject::tr( "Configuration not found in database" ); }
41 
43  const QSslCertificate &cert,
44  const QString &hostport,
45  const QList<QSslCertificate> &connectionCAs )
46  : QWidget( parent )
47  , mCert( nullptr )
48  , mConnectionCAs( connectionCAs )
49 {
50  if ( QgsApplication::authManager()->isDisabled() )
51  {
52  mDisabled = true;
53  mAuthNotifyLayout = new QVBoxLayout;
54  this->setLayout( mAuthNotifyLayout );
55  mAuthNotify = new QLabel( QgsApplication::authManager()->disabledMessage(), this );
56  mAuthNotifyLayout->addWidget( mAuthNotify );
57  }
58  else
59  {
60  setupUi( this );
61  connect( btnCertInfo, &QToolButton::clicked, this, &QgsAuthSslConfigWidget::btnCertInfo_clicked );
62 
63  connect( grpbxSslConfig, &QGroupBox::toggled, this, &QgsAuthSslConfigWidget::configEnabledChanged );
66 
67  setUpSslConfigTree();
68 
69  lblLoadedConfig->setVisible( false );
70  lblLoadedConfig->clear();
71 
72  connect( leHost, &QLineEdit::textChanged,
74 
75  if ( !cert.isNull() )
76  {
77  setSslCertificate( cert, hostport );
78  }
79  }
80 }
81 
83 {
84  if ( mDisabled )
85  {
86  return nullptr;
87  }
88  return grpbxCert;
89 }
90 
92 {
93  if ( mDisabled )
94  {
95  return nullptr;
96  }
97  return grpbxSslConfig;
98 }
99 
100 // private
101 QTreeWidgetItem *QgsAuthSslConfigWidget::addRootItem( const QString &label )
102 {
103  QTreeWidgetItem *item = new QTreeWidgetItem(
104  QStringList() << label,
105  static_cast<int>( ConfigParent ) );
106  setItemBold_( item );
107  item->setTextAlignment( 0, Qt::AlignVCenter );
108  item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
109  treeSslConfig->insertTopLevelItem( treeSslConfig->topLevelItemCount(), item );
110 
111  return item;
112 }
113 
114 void QgsAuthSslConfigWidget::setUpSslConfigTree()
115 {
116  treeSslConfig->setColumnCount( 1 );
117 
118  // add config field names
119  mProtocolItem = addRootItem( tr( "Protocol" ) );
120  mProtocolCmbBx = new QComboBox( treeSslConfig );
121  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::SecureProtocols ),
122  static_cast<int>( QSsl::SecureProtocols ) );
123  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::TlsV1SslV3 ),
124  static_cast<int>( QSsl::TlsV1SslV3 ) );
125  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::TlsV1 ),
126  static_cast<int>( QSsl::TlsV1 ) );
127  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::SslV3 ),
128  static_cast<int>( QSsl::SslV3 ) );
129  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::SslV2 ),
130  static_cast<int>( QSsl::SslV2 ) );
131  mProtocolCmbBx->setMaximumWidth( 300 );
132  mProtocolCmbBx->setCurrentIndex( 0 );
133  QTreeWidgetItem *protocolitem = new QTreeWidgetItem(
134  mProtocolItem,
135  QStringList() << QString(),
136  static_cast<int>( ConfigItem ) );
137  protocolitem->setFlags( protocolitem->flags() & ~Qt::ItemIsSelectable );
138  treeSslConfig->setItemWidget( protocolitem, 0, mProtocolCmbBx );
139  mProtocolItem->setExpanded( true );
140 
141  mVerifyModeItem = addRootItem( tr( "Peer verification" ) );
142  mVerifyPeerCmbBx = new QComboBox( treeSslConfig );
143  mVerifyPeerCmbBx->addItem( tr( "Verify peer certs" ),
144  static_cast<int>( QSslSocket::VerifyPeer ) );
145  mVerifyPeerCmbBx->addItem( tr( "Do not verify peer certs" ),
146  static_cast<int>( QSslSocket::VerifyNone ) );
147  mVerifyPeerCmbBx->setMaximumWidth( 300 );
148  mVerifyPeerCmbBx->setCurrentIndex( 0 );
149  QTreeWidgetItem *peerverifycmbxitem = new QTreeWidgetItem(
150  mVerifyModeItem,
151  QStringList() << QString(),
152  static_cast<int>( ConfigItem ) );
153  peerverifycmbxitem->setFlags( peerverifycmbxitem->flags() & ~Qt::ItemIsSelectable );
154  treeSslConfig->setItemWidget( peerverifycmbxitem, 0, mVerifyPeerCmbBx );
155  mVerifyModeItem->setExpanded( true );
156 
157  mVerifyDepthItem = addRootItem( tr( "Peer verification depth (0 = complete cert chain)" ) );
158  mVerifyDepthSpnBx = new QSpinBox( treeSslConfig );
159  mVerifyDepthSpnBx->setMinimum( 0 );
160  mVerifyDepthSpnBx->setMaximum( 10 );
161  mVerifyDepthSpnBx->setMaximumWidth( 200 );
162  mVerifyDepthSpnBx->setAlignment( Qt::AlignHCenter );
163  QTreeWidgetItem *peerverifyspnbxitem = new QTreeWidgetItem(
164  mVerifyDepthItem,
165  QStringList() << QString(),
166  static_cast<int>( ConfigItem ) );
167  peerverifyspnbxitem->setFlags( peerverifyspnbxitem->flags() & ~Qt::ItemIsSelectable );
168  treeSslConfig->setItemWidget( peerverifyspnbxitem, 0, mVerifyDepthSpnBx );
169  mVerifyDepthItem->setExpanded( true );
170 
171  mIgnoreErrorsItem = addRootItem( tr( "Ignore errors" ) );
172 
173  QList<QPair<QSslError::SslError, QString> > errenums = QgsAuthCertUtils::sslErrorEnumStrings();
174  for ( int i = 0; i < errenums.size(); i++ )
175  {
176  QTreeWidgetItem *item = new QTreeWidgetItem(
177  mIgnoreErrorsItem,
178  QStringList() << errenums.at( i ).second,
179  static_cast<int>( ConfigItem ) );
180  item->setCheckState( 0, Qt::Unchecked );
181  item->setTextAlignment( 0, Qt::AlignVCenter );
182  item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
183  item->setData( 0, Qt::UserRole, errenums.at( i ).first );
184  }
185  mIgnoreErrorsItem->setExpanded( true );
186 }
187 
189 {
190  QgsAuthConfigSslServer config;
191  if ( mDisabled )
192  {
193  return config;
194  }
195  config.setSslCertificate( mCert );
196  config.setSslHostPort( leHost->text() );
197  config.setSslProtocol( sslProtocol() );
201  return config;
202 }
203 
205 {
206  if ( mDisabled )
207  {
208  return QSslCertificate();
209  }
210  return mCert;
211 }
212 
214 {
215  if ( mDisabled )
216  {
217  return QString();
218  }
219  return leHost->text();
220 }
221 
223 {
224  if ( mDisabled )
225  {
226  return;
227  }
228  if ( grpbxSslConfig->isCheckable() )
229  {
230  grpbxSslConfig->setChecked( enable );
231  }
232 }
233 
234 void QgsAuthSslConfigWidget::setSslCertificate( const QSslCertificate &cert, const QString &hostport )
235 {
236  if ( mDisabled )
237  {
238  return;
239  }
240  if ( cert.isNull() )
241  {
242  return;
243  }
244  mCert = cert;
245 
246  if ( !hostport.isEmpty() )
247  {
248  setSslHost( hostport );
249  }
250 
251  QString sha( QgsAuthCertUtils::shaHexForCert( cert ) );
252  QgsAuthConfigSslServer config(
253  QgsApplication::authManager()->sslCertCustomConfig( sha, hostport.isEmpty() ? sslHost() : hostport ) );
254 
255  emit certFoundInAuthDatabase( !config.isNull() );
256 
257  lblLoadedConfig->setVisible( true );
258  if ( !config.isNull() )
259  {
260  loadSslCustomConfig( config );
261  leCommonName->setStyleSheet( QgsAuthGuiUtils::greenTextStyleSheet() );
262  }
263  else
264  {
265  lblLoadedConfig->setText( configNotFoundText_() );
266  leCommonName->setText( QgsAuthCertUtils::resolvedCertName( mCert ) );
267  leCommonName->setStyleSheet( QgsAuthGuiUtils::orangeTextStyleSheet() );
268  }
269  validateHostPortText( leHost->text() );
270 }
271 
273 {
274  if ( mDisabled )
275  {
276  return;
277  }
279  if ( config.isNull() )
280  {
281  QgsDebugMsg( QStringLiteral( "Passed-in SSL custom config is null" ) );
282  return;
283  }
284 
285  QSslCertificate cert( config.sslCertificate() );
286  if ( cert.isNull() )
287  {
288  QgsDebugMsg( QStringLiteral( "SSL custom config's cert is null" ) );
289  return;
290  }
291 
292  enableSslCustomOptions( true );
293  mCert = cert;
294  leCommonName->setText( QgsAuthCertUtils::resolvedCertName( cert ) );
295  leHost->setText( config.sslHostPort() );
297  setSslProtocol( config.sslProtocol() );
299 
300  lblLoadedConfig->setVisible( true );
301  lblLoadedConfig->setText( configFoundText_() );
302 }
303 
305 {
306  if ( mDisabled )
307  {
308  return;
309  }
310  if ( !QgsApplication::authManager()->storeSslCertCustomConfig( sslCustomConfig() ) )
311  {
312  QgsDebugMsg( QStringLiteral( "SSL custom config FAILED to store in authentication database" ) );
313  }
314 }
315 
317 {
318  if ( mDisabled )
319  {
320  return;
321  }
322  mCert.clear();
323  mConnectionCAs.clear();
324  leCommonName->clear();
325  leCommonName->setStyleSheet( QString() );
326  leHost->clear();
327 
328  lblLoadedConfig->setVisible( false );
329  lblLoadedConfig->clear();
333  enableSslCustomOptions( false );
334 }
335 
337 {
338  if ( mDisabled )
339  {
340  return QSsl::UnknownProtocol;
341  }
342  return ( QSsl::SslProtocol )mProtocolCmbBx->currentData().toInt();
343 }
344 
345 void QgsAuthSslConfigWidget::setSslProtocol( QSsl::SslProtocol protocol )
346 {
347  if ( mDisabled )
348  {
349  return;
350  }
351  int indx( mProtocolCmbBx->findData( static_cast<int>( protocol ) ) );
352  mProtocolCmbBx->setCurrentIndex( indx );
353 }
354 
356 {
357  if ( mDisabled )
358  {
359  return;
360  }
361  mProtocolCmbBx->setCurrentIndex( 0 );
362 }
363 
364 void QgsAuthSslConfigWidget::appendSslIgnoreErrors( const QList<QSslError> &errors )
365 {
366  if ( mDisabled )
367  {
368  return;
369  }
370  enableSslCustomOptions( true );
371 
372  QList<QSslError::SslError> errenums;
373  const auto constErrors = errors;
374  for ( const QSslError &err : constErrors )
375  {
376  errenums << err.error();
377  }
378 
379  for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
380  {
381  QTreeWidgetItem *item( mIgnoreErrorsItem->child( i ) );
382  if ( errenums.contains( ( QSslError::SslError )item->data( 0, Qt::UserRole ).toInt() ) )
383  {
384  item->setCheckState( 0, Qt::Checked );
385  }
386  }
387 }
388 
389 void QgsAuthSslConfigWidget::setSslIgnoreErrorEnums( const QList<QSslError::SslError> &errorenums )
390 {
391  if ( mDisabled )
392  {
393  return;
394  }
395  QList<QSslError> errors;
396  const auto constErrorenums = errorenums;
397  for ( QSslError::SslError errorenum : constErrorenums )
398  {
399  errors << QSslError( errorenum );
400  }
401  setSslIgnoreErrors( errors );
402 }
403 
404 void QgsAuthSslConfigWidget::setSslIgnoreErrors( const QList<QSslError> &errors )
405 {
406  if ( mDisabled )
407  {
408  return;
409  }
410  if ( errors.isEmpty() )
411  {
412  return;
413  }
414 
415  enableSslCustomOptions( true );
416 
417  QList<QSslError::SslError> errenums;
418  const auto constErrors = errors;
419  for ( const QSslError &err : constErrors )
420  {
421  errenums << err.error();
422  }
423 
424  for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
425  {
426  QTreeWidgetItem *item( mIgnoreErrorsItem->child( i ) );
427  bool enable( errenums.contains( ( QSslError::SslError )item->data( 0, Qt::UserRole ).toInt() ) );
428  item->setCheckState( 0, enable ? Qt::Checked : Qt::Unchecked );
429  }
430 }
431 
433 {
434  if ( mDisabled )
435  {
436  return;
437  }
438  for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
439  {
440  mIgnoreErrorsItem->child( i )->setCheckState( 0, Qt::Unchecked );
441  }
442 }
443 
444 const QList<QSslError::SslError> QgsAuthSslConfigWidget::sslIgnoreErrorEnums()
445 {
446  QList<QSslError::SslError> errs;
447  if ( mDisabled )
448  {
449  return errs;
450  }
451  for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
452  {
453  QTreeWidgetItem *item( mIgnoreErrorsItem->child( i ) );
454  if ( item->checkState( 0 ) == Qt::Checked )
455  {
456  errs.append( ( QSslError::SslError )item->data( 0, Qt::UserRole ).toInt() );
457  }
458  }
459  return errs;
460 }
461 
462 QSslSocket::PeerVerifyMode QgsAuthSslConfigWidget::sslPeerVerifyMode()
463 {
464  if ( mDisabled )
465  {
466  return QSslSocket::AutoVerifyPeer;
467  }
468  return ( QSslSocket::PeerVerifyMode )mVerifyPeerCmbBx->currentData().toInt();
469 }
470 
472 {
473  if ( mDisabled )
474  {
475  return 0;
476  }
477  return mVerifyDepthSpnBx->value();
478 }
479 
480 void QgsAuthSslConfigWidget::setSslPeerVerify( QSslSocket::PeerVerifyMode mode, int modedepth )
481 {
482  if ( mDisabled )
483  {
484  return;
485  }
486  enableSslCustomOptions( true );
487 
488  int indx( mVerifyPeerCmbBx->findData( static_cast<int>( mode ) ) );
489  mVerifyPeerCmbBx->setCurrentIndex( indx );
490 
491  mVerifyDepthSpnBx->setValue( modedepth );
492 }
493 
495 {
496  if ( mDisabled )
497  {
498  return;
499  }
500  mVerifyPeerCmbBx->setCurrentIndex( 0 );
501  mVerifyDepthSpnBx->setValue( 0 );
502 }
503 
505 {
506  if ( mDisabled )
507  {
508  return false;
509  }
510  bool cansave = ( isEnabled()
511  && ( grpbxSslConfig->isCheckable() ? grpbxSslConfig->isChecked() : true )
512  && validateHostPort( leHost->text() ) );
513  if ( mCanSave != cansave )
514  {
515  mCanSave = cansave;
516  emit readyToSaveChanged( cansave );
517  }
518  return cansave;
519 }
520 
521 void QgsAuthSslConfigWidget::setSslHost( const QString &host )
522 {
523  if ( mDisabled )
524  {
525  return;
526  }
527  leHost->setText( host );
528 }
529 
530 bool QgsAuthSslConfigWidget::validateHostPort( const QString &txt )
531 {
532  QString hostport( txt );
533  if ( hostport.isEmpty() )
534  {
535  return false;
536  }
537 
538  // TODO: add QRegex checks against valid IP and domain.tld input
539  // i.e., currently accepts unlikely (though maybe valid) host:port combo, like 'a:1'
540  QString urlbase( QStringLiteral( "https://%1" ).arg( hostport ) );
541  QUrl url( urlbase );
542  return ( !url.host().isEmpty() && QString::number( url.port() ).size() > 0
543  && QStringLiteral( "https://%1:%2" ).arg( url.host() ).arg( url.port() ) == urlbase );
544 }
545 
547 {
548  if ( mDisabled )
549  {
550  return;
551  }
552  bool valid = validateHostPort( txt );
553  leHost->setStyleSheet( valid ? QgsAuthGuiUtils::greenTextStyleSheet()
555  emit hostPortValidityChanged( valid );
556 }
557 
559 {
560  if ( mDisabled )
561  {
562  return;
563  }
564  grpbxSslConfig->setCheckable( checkable );
565  if ( !checkable )
566  {
567  grpbxSslConfig->setEnabled( true );
568  }
569 }
570 
571 void QgsAuthSslConfigWidget::btnCertInfo_clicked()
572 {
573  if ( mCert.isNull() )
574  {
575  return;
576  }
577 
578  QgsAuthCertInfoDialog *dlg = new QgsAuthCertInfoDialog( mCert, false, this, mConnectionCAs );
579  dlg->setWindowModality( Qt::WindowModal );
580  dlg->resize( 675, 500 );
581  dlg->exec();
582  dlg->deleteLater();
583 }
584 
585 
587 
588 QgsAuthSslConfigDialog::QgsAuthSslConfigDialog( QWidget *parent, const QSslCertificate &cert, const QString &hostport )
589  : QDialog( parent )
590 
591 {
592  setWindowTitle( tr( "Custom Certificate Configuration" ) );
593  QVBoxLayout *layout = new QVBoxLayout( this );
594  layout->setMargin( 6 );
595 
596  mSslConfigWdgt = new QgsAuthSslConfigWidget( this, cert, hostport );
597  connect( mSslConfigWdgt, &QgsAuthSslConfigWidget::readyToSaveChanged,
598  this, &QgsAuthSslConfigDialog::checkCanSave );
599  layout->addWidget( mSslConfigWdgt );
600 
601  QDialogButtonBox *buttonBox = new QDialogButtonBox(
602  QDialogButtonBox::Close | QDialogButtonBox::Save, Qt::Horizontal, this );
603 
604  buttonBox->button( QDialogButtonBox::Close )->setDefault( true );
605  mSaveButton = buttonBox->button( QDialogButtonBox::Save );
606  connect( buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close );
607  connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsAuthSslConfigDialog::accept );
608  layout->addWidget( buttonBox );
609 
610  setLayout( layout );
611  mSaveButton->setEnabled( mSslConfigWdgt->readyToSave() );
612 }
613 
615 {
616  mSslConfigWdgt->saveSslCertConfig();
617  QDialog::accept();
618 }
619 
620 void QgsAuthSslConfigDialog::checkCanSave( bool cansave )
621 {
622  mSaveButton->setEnabled( cansave );
623 }
bool isNull() const
Whether configuration is null (missing components)
void resetSslProtocol()
Reset the SSL protocol to use in connections to the default.
QSsl::SslProtocol sslProtocol()
Gets the SSL protocol used for connections.
int sslPeerVerifyDepth() const
Number or SSL client&#39;s peer to verify in connections.
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QGroupBox * sslConfigGroupBox()
Access to the SSL configuration&#39;s group box widget.
Configuration container for SSL server connection exceptions or overrides.
void enableSslCustomOptions(bool enable)
Enable or disable the custom options widget.
void resetSslCertConfig()
Clear the current SSL server configuration and disabled it.
QGroupBox * certificateGroupBox()
Access to the certificate&#39;s group box widget.
QSsl::SslProtocol sslProtocol() const
SSL server protocol to use in connections.
int sslPeerVerifyDepth()
Gets the client&#39;s peer verify depth for connections.
QSslSocket::PeerVerifyMode sslPeerVerifyMode() const
SSL client&#39;s peer verify mode to use in connections.
void setSslPeerVerifyMode(QSslSocket::PeerVerifyMode mode)
Sets SSL client&#39;s peer verify mode to use in connections.
void resetSslPeerVerify()
Reset the client&#39;s peer verify mode for connections to default.
void certFoundInAuthDatabase(bool found)
Emitted when an certificate of same SHA hash is found in authentication database. ...
void setSslProtocol(QSsl::SslProtocol protocol)
Sets the SSL protocol to use in connections.
QgsAuthSslConfigWidget(QWidget *parent=nullptr, const QSslCertificate &cert=QSslCertificate(), const QString &hostport=QString(), const QList< QSslCertificate > &connectionCAs=QList< QSslCertificate >())
Construct a widget for editing an SSL server certificate configuration.
Dialog wrapper for widget displaying detailed info on a certificate and its hierarchical trust chain...
static QString greenTextStyleSheet(const QString &selector="*")
Green text stylesheet representing valid, trusted, etc. certificate.
void validateHostPortText(const QString &txt)
Parse string for host:port.
void configEnabledChanged(bool enabled)
Emitted when the enabled state of the configuration changes.
const QString sslHost()
Gets the host:port to associate with the server certificate.
QgsAuthSslConfigDialog(QWidget *parent=nullptr, const QSslCertificate &cert=QSslCertificate(), const QString &hostport=QString())
Construct wrapper dialog for the SSL config widget.
void setSslIgnoreErrors(const QList< QSslError > &errors)
Sets the SSL errors to ignore for the connection.
Widget for editing an SSL server configuration.
void appendSslIgnoreErrors(const QList< QSslError > &errors)
Add to SSL errors to ignore for the connection.
void setSslCertificate(const QSslCertificate &cert, const QString &hostport=QString())
Sets SSl certificate and any associated host:port.
const QString sslHostPort() const
Server host:port string.
const QList< QSslError::SslError > sslIgnoredErrorEnums() const
SSL server errors (as enum list) to ignore in connections.
void setSslHostPort(const QString &hostport)
Sets server host:port string.
void setSslIgnoreErrorEnums(const QList< QSslError::SslError > &errorenums)
Sets the SSL errors (as enums) to ignore for the connection.
void setConfigCheckable(bool checkable)
Sets whether the config group box is checkable.
static QString getSslProtocolName(QSsl::SslProtocol protocol)
SSL Protocol name strings per enum.
void setSslPeerVerify(QSslSocket::PeerVerifyMode mode, int modedepth)
Sets the client&#39;s peer verify mode for connections.
void setSslProtocol(QSsl::SslProtocol protocol)
Sets SSL server protocol to use in connections.
static QString shaHexForCert(const QSslCertificate &cert, bool formatted=false)
Gets the sha1 hash for certificate.
static QgsAuthManager * authManager()
Returns the application&#39;s authentication manager instance.
void hostPortValidityChanged(bool valid)
Emitted when the validity of the host:port changes.
void resetSslIgnoreErrors()
Clear the SSL errors to ignore for the connection.
static QString redTextStyleSheet(const QString &selector="*")
Red text stylesheet representing invalid, untrusted, etc. certificate.
bool readyToSave()
Verify if the configuration if ready to save.
const QSslCertificate sslCertificate() const
Server certificate object.
void loadSslCustomConfig(const QgsAuthConfigSslServer &config=QgsAuthConfigSslServer())
Load an existing SSL server configuration.
void setSslIgnoredErrorEnums(const QList< QSslError::SslError > &errors)
Sets SSL server errors (as enum list) to ignore in connections.
void setSslHost(const QString &host)
Sets the host of the server.
const QSslCertificate sslCertificate()
Gets the SSL server certificate.
void readyToSaveChanged(bool cansave)
Emitted when the configuration can be saved changes.
QSslSocket::PeerVerifyMode sslPeerVerifyMode()
Gets the client&#39;s peer verify mode for connections.
void setSslPeerVerifyDepth(int depth)
Set number or SSL client&#39;s peer to verify in connections.
void saveSslCertConfig()
Save the current SSL server configuration to the authentication database.
static QList< QPair< QSslError::SslError, QString > > sslErrorEnumStrings()
Gets short strings describing SSL errors.
void setSslCertificate(const QSslCertificate &cert)
Sets server certificate object.
static QString resolvedCertName(const QSslCertificate &cert, bool issuer=false)
Gets the general name via RFC 5280 resolution.
const QgsAuthConfigSslServer sslCustomConfig()
Gets the SSL configuration.
static QString orangeTextStyleSheet(const QString &selector="*")
Orange text stylesheet representing loaded component, but not stored in database. ...
const QList< QSslError::SslError > sslIgnoreErrorEnums()
Gets list of the SSL errors (as enums) to be ignored for connections.