QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
29 
30 static void setItemBold_( QTreeWidgetItem* item )
31 {
32  item->setFirstColumnSpanned( true );
33  QFont secf( item->font( 0 ) );
34  secf.setBold( true );
35  item->setFont( 0, secf );
36 }
37 
38 static const QString configFoundText_() { return QObject::tr( "Configuration loaded from database" ); }
39 static const QString configNotFoundText_() { return QObject::tr( "Configuration not found in database" ); }
40 
42  const QSslCertificate& cert,
43  const QString &hostport,
44  const QList<QSslCertificate> &connectionCAs )
45  : QWidget( parent )
46  , mCert( nullptr )
47  , mConnectionCAs( connectionCAs )
48  , mProtocolItem( nullptr )
49  , mProtocolCmbBx( nullptr )
50  , mIgnoreErrorsItem( nullptr )
51  , mVerifyModeItem( nullptr )
52  , mVerifyPeerCmbBx( nullptr )
53  , mVerifyDepthItem( nullptr )
54  , mVerifyDepthSpnBx( nullptr )
55  , mCanSave( false )
56  , mDisabled( false )
57  , mAuthNotifyLayout( nullptr )
58  , mAuthNotify( nullptr )
59 {
60  if ( QgsAuthManager::instance()->isDisabled() )
61  {
62  mDisabled = true;
63  mAuthNotifyLayout = new QVBoxLayout;
64  this->setLayout( mAuthNotifyLayout );
65  mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
66  mAuthNotifyLayout->addWidget( mAuthNotify );
67  }
68  else
69  {
70  setupUi( this );
71 
72  connect( grpbxSslConfig, SIGNAL( toggled( bool ) ), this, SIGNAL( configEnabledChanged( bool ) ) );
73  connect( this, SIGNAL( configEnabledChanged( bool ) ), this, SLOT( readyToSave() ) );
74  connect( this, SIGNAL( hostPortValidityChanged( bool ) ), this, SLOT( readyToSave() ) );
75 
76  setUpSslConfigTree();
77 
78  lblLoadedConfig->setVisible( false );
79  lblLoadedConfig->setText( "" );
80 
81  connect( leHost, SIGNAL( textChanged( QString ) ),
82  this, SLOT( validateHostPortText( QString ) ) );
83 
84  if ( !cert.isNull() )
85  {
86  setSslCertificate( cert, hostport );
87  }
88  }
89 }
90 
92 {
93 }
94 
96 {
97  if ( mDisabled )
98  {
99  return nullptr;
100  }
101  return grpbxCert;
102 }
103 
105 {
106  if ( mDisabled )
107  {
108  return nullptr;
109  }
110  return grpbxSslConfig;
111 }
112 
113 // private
114 QTreeWidgetItem* QgsAuthSslConfigWidget::addRootItem( const QString &label )
115 {
116  QTreeWidgetItem *item = new QTreeWidgetItem(
117  QStringList() << label,
118  ( int )ConfigParent );
119  setItemBold_( item );
120  item->setTextAlignment( 0, Qt::AlignVCenter );
121  item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
122  treeSslConfig->insertTopLevelItem( treeSslConfig->topLevelItemCount(), item );
123 
124  return item;
125 }
126 
127 void QgsAuthSslConfigWidget::setUpSslConfigTree()
128 {
129  treeSslConfig->setColumnCount( 1 );
130 
131  // add config field names
132  mProtocolItem = addRootItem( tr( "Protocol" ) );
133  mProtocolCmbBx = new QComboBox( treeSslConfig );
134 #if QT_VERSION >= 0x040800
135  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::SecureProtocols ),
136  ( int )QSsl::SecureProtocols );
137  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::TlsV1SslV3 ),
138  ( int )QSsl::TlsV1SslV3 );
139 #endif
140  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::TlsV1 ),
141  ( int )QSsl::TlsV1 );
142  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::SslV3 ),
143  ( int )QSsl::SslV3 );
144  mProtocolCmbBx->addItem( QgsAuthCertUtils::getSslProtocolName( QSsl::SslV2 ),
145  ( int )QSsl::SslV2 );
146  mProtocolCmbBx->setMaximumWidth( 300 );
147  mProtocolCmbBx->setCurrentIndex( 0 );
148  QTreeWidgetItem *protocolitem = new QTreeWidgetItem(
149  mProtocolItem,
150  QStringList() << "",
151  ( int )ConfigItem );
152  protocolitem->setFlags( protocolitem->flags() & ~Qt::ItemIsSelectable );
153  treeSslConfig->setItemWidget( protocolitem, 0, mProtocolCmbBx );
154  mProtocolItem->setExpanded( true );
155 
156  mVerifyModeItem = addRootItem( tr( "Peer verification" ) );
157  mVerifyPeerCmbBx = new QComboBox( treeSslConfig );
158  mVerifyPeerCmbBx->addItem( tr( "Verify peer certs" ),
159  ( int )QSslSocket::VerifyPeer );
160  mVerifyPeerCmbBx->addItem( tr( "Do not verify peer certs" ),
161  ( int )QSslSocket::VerifyNone );
162  mVerifyPeerCmbBx->setMaximumWidth( 300 );
163  mVerifyPeerCmbBx->setCurrentIndex( 0 );
164  QTreeWidgetItem *peerverifycmbxitem = new QTreeWidgetItem(
165  mVerifyModeItem,
166  QStringList() << "",
167  ( int )ConfigItem );
168  peerverifycmbxitem->setFlags( peerverifycmbxitem->flags() & ~Qt::ItemIsSelectable );
169  treeSslConfig->setItemWidget( peerverifycmbxitem, 0, mVerifyPeerCmbBx );
170  mVerifyModeItem->setExpanded( true );
171 
172  mVerifyDepthItem = addRootItem( tr( "Peer verification depth (0 = complete cert chain)" ) );
173  mVerifyDepthSpnBx = new QSpinBox( treeSslConfig );
174  mVerifyDepthSpnBx->setMinimum( 0 );
175  mVerifyDepthSpnBx->setMaximum( 10 );
176  mVerifyDepthSpnBx->setMaximumWidth( 200 );
177  mVerifyDepthSpnBx->setAlignment( Qt::AlignHCenter );
178  QTreeWidgetItem *peerverifyspnbxitem = new QTreeWidgetItem(
179  mVerifyDepthItem,
180  QStringList() << "",
181  ( int )ConfigItem );
182  peerverifyspnbxitem->setFlags( peerverifyspnbxitem->flags() & ~Qt::ItemIsSelectable );
183  treeSslConfig->setItemWidget( peerverifyspnbxitem, 0, mVerifyDepthSpnBx );
184  mVerifyDepthItem->setExpanded( true );
185 
186  mIgnoreErrorsItem = addRootItem( tr( "Ignore errors" ) );
187 
189  for ( int i = 0; i < errenums.size(); i++ )
190  {
191  QTreeWidgetItem *item = new QTreeWidgetItem(
192  mIgnoreErrorsItem,
193  QStringList() << errenums.at( i ).second,
194  ( int )ConfigItem );
195  item->setCheckState( 0, Qt::Unchecked );
196  item->setTextAlignment( 0, Qt::AlignVCenter );
197  item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
198  item->setData( 0, Qt::UserRole, errenums.at( i ).first );
199  }
200  mIgnoreErrorsItem->setExpanded( true );
201 }
202 
204 {
205  QgsAuthConfigSslServer config;
206  if ( mDisabled )
207  {
208  return config;
209  }
210  config.setSslCertificate( mCert );
211  config.setSslHostPort( leHost->text() );
212  config.setSslProtocol( sslProtocol() );
216  return config;
217 }
218 
220 {
221  if ( mDisabled )
222  {
223  return QSslCertificate();
224  }
225  return mCert;
226 }
227 
229 {
230  if ( mDisabled )
231  {
232  return QString();
233  }
234  return leHost->text();
235 }
236 
238 {
239  if ( mDisabled )
240  {
241  return;
242  }
243  if ( grpbxSslConfig->isCheckable() )
244  {
245  grpbxSslConfig->setChecked( enable );
246  }
247 }
248 
250 {
251  if ( mDisabled )
252  {
253  return;
254  }
255  if ( cert.isNull() )
256  {
257  return;
258  }
259  mCert = cert;
260 
261  if ( !hostport.isEmpty() )
262  {
263  setSslHost( hostport );
264  }
265 
267  QgsAuthConfigSslServer config(
268  QgsAuthManager::instance()->getSslCertCustomConfig( sha, hostport.isEmpty() ? sslHost() : hostport ) );
269 
270  emit certFoundInAuthDatabase( !config.isNull() );
271 
272  lblLoadedConfig->setVisible( true );
273  if ( !config.isNull() )
274  {
275  loadSslCustomConfig( config );
276  leCommonName->setStyleSheet( QgsAuthGuiUtils::greenTextStyleSheet() );
277  }
278  else
279  {
280  lblLoadedConfig->setText( configNotFoundText_() );
281  leCommonName->setText( QgsAuthCertUtils::resolvedCertName( mCert ) );
282  leCommonName->setStyleSheet( QgsAuthGuiUtils::orangeTextStyleSheet() );
283  }
284  validateHostPortText( leHost->text() );
285 }
286 
288 {
289  if ( mDisabled )
290  {
291  return;
292  }
294  if ( config.isNull() )
295  {
296  QgsDebugMsg( "Passed-in SSL custom config is null" );
297  return;
298  }
299 
300  QSslCertificate cert( config.sslCertificate() );
301  if ( cert.isNull() )
302  {
303  QgsDebugMsg( "SSL custom config's cert is null" );
304  return;
305  }
306 
307  enableSslCustomOptions( true );
308  mCert = cert;
309  leCommonName->setText( QgsAuthCertUtils::resolvedCertName( cert ) );
310  leHost->setText( config.sslHostPort() );
312  setSslProtocol( config.sslProtocol() );
314 
315  lblLoadedConfig->setVisible( true );
316  lblLoadedConfig->setText( configFoundText_() );
317 }
318 
320 {
321  if ( mDisabled )
322  {
323  return;
324  }
325  if ( !QgsAuthManager::instance()->storeSslCertCustomConfig( sslCustomConfig() ) )
326  {
327  QgsDebugMsg( "SSL custom config FAILED to store in authentication database" );
328  }
329 }
330 
332 {
333  if ( mDisabled )
334  {
335  return;
336  }
337  mCert.clear();
338  mConnectionCAs.clear();
339  leCommonName->clear();
340  leCommonName->setStyleSheet( "" );
341  leHost->clear();
342 
343  lblLoadedConfig->setVisible( false );
344  lblLoadedConfig->setText( "" );
348  enableSslCustomOptions( false );
349 }
350 
352 {
353  if ( mDisabled )
354  {
355  return QSsl::UnknownProtocol;
356  }
357  return ( QSsl::SslProtocol )mProtocolCmbBx->itemData( mProtocolCmbBx->currentIndex() ).toInt();
358 }
359 
360 void QgsAuthSslConfigWidget::setSslProtocol( QSsl::SslProtocol protocol )
361 {
362  if ( mDisabled )
363  {
364  return;
365  }
366  int indx( mProtocolCmbBx->findData(( int )protocol ) );
367  mProtocolCmbBx->setCurrentIndex( indx );
368 }
369 
371 {
372  if ( mDisabled )
373  {
374  return;
375  }
376  mProtocolCmbBx->setCurrentIndex( 0 );
377 }
378 
380 {
381  if ( mDisabled )
382  {
383  return;
384  }
385  enableSslCustomOptions( true );
386 
388  Q_FOREACH ( const QSslError& err, errors )
389  {
390  errenums << err.error();
391  }
392 
393  for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
394  {
395  QTreeWidgetItem *item( mIgnoreErrorsItem->child( i ) );
396  if ( errenums.contains(( QSslError::SslError )item->data( 0, Qt::UserRole ).toInt() ) )
397  {
398  item->setCheckState( 0, Qt::Checked );
399  }
400  }
401 }
402 
404 {
405  if ( mDisabled )
406  {
407  return;
408  }
409  QList<QSslError> errors;
410  Q_FOREACH ( QSslError::SslError errorenum, errorenums )
411  {
412  errors << QSslError( errorenum );
413  }
414  setSslIgnoreErrors( errors );
415 }
416 
418 {
419  if ( mDisabled )
420  {
421  return;
422  }
423  if ( errors.isEmpty() )
424  {
425  return;
426  }
427 
428  enableSslCustomOptions( true );
429 
431  Q_FOREACH ( const QSslError& err, errors )
432  {
433  errenums << err.error();
434  }
435 
436  for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
437  {
438  QTreeWidgetItem *item( mIgnoreErrorsItem->child( i ) );
439  bool enable( errenums.contains(( QSslError::SslError )item->data( 0, Qt::UserRole ).toInt() ) );
440  item->setCheckState( 0, enable ? Qt::Checked : Qt::Unchecked );
441  }
442 }
443 
445 {
446  if ( mDisabled )
447  {
448  return;
449  }
450  for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
451  {
452  mIgnoreErrorsItem->child( i )->setCheckState( 0, Qt::Unchecked );
453  }
454 }
455 
457 {
459  if ( mDisabled )
460  {
461  return errs;
462  }
463  for ( int i = 0; i < mIgnoreErrorsItem->childCount(); i++ )
464  {
465  QTreeWidgetItem *item( mIgnoreErrorsItem->child( i ) );
466  if ( item->checkState( 0 ) == Qt::Checked )
467  {
468  errs.append(( QSslError::SslError )item->data( 0, Qt::UserRole ).toInt() );
469  }
470  }
471  return errs;
472 }
473 
474 QSslSocket::PeerVerifyMode QgsAuthSslConfigWidget::sslPeerVerifyMode()
475 {
476  if ( mDisabled )
477  {
478  return QSslSocket::AutoVerifyPeer;
479  }
480  return ( QSslSocket::PeerVerifyMode )mVerifyPeerCmbBx->itemData( mVerifyPeerCmbBx->currentIndex() ).toInt();
481 }
482 
484 {
485  if ( mDisabled )
486  {
487  return 0;
488  }
489  return mVerifyDepthSpnBx->value();
490 }
491 
492 void QgsAuthSslConfigWidget::setSslPeerVerify( QSslSocket::PeerVerifyMode mode, int modedepth )
493 {
494  if ( mDisabled )
495  {
496  return;
497  }
498  enableSslCustomOptions( true );
499 
500  int indx( mVerifyPeerCmbBx->findData(( int )mode ) );
501  mVerifyPeerCmbBx->setCurrentIndex( indx );
502 
503  mVerifyDepthSpnBx->setValue( modedepth );
504 }
505 
507 {
508  if ( mDisabled )
509  {
510  return;
511  }
512  mVerifyPeerCmbBx->setCurrentIndex( 0 );
513  mVerifyDepthSpnBx->setValue( 0 );
514 }
515 
517 {
518  if ( mDisabled )
519  {
520  return false;
521  }
522  bool cansave = ( isEnabled()
523  && ( grpbxSslConfig->isCheckable() ? grpbxSslConfig->isChecked() : true )
524  && validateHostPort( leHost->text() ) );
525  if ( mCanSave != cansave )
526  {
527  mCanSave = cansave;
528  emit readyToSaveChanged( cansave );
529  }
530  return cansave;
531 }
532 
534 {
535  if ( mDisabled )
536  {
537  return;
538  }
539  leHost->setText( host );
540 }
541 
542 bool QgsAuthSslConfigWidget::validateHostPort( const QString &txt )
543 {
544  QString hostport( txt );
545  if ( hostport.isEmpty() )
546  {
547  return false;
548  }
549 
550  // TODO: add QRegex checks against valid IP and domain.tld input
551  // i.e., currently accepts unlikely (though maybe valid) host:port combo, like 'a:1'
552  QString urlbase( QString( "https://%1" ).arg( hostport ) );
553  QUrl url( urlbase );
554  return ( !url.host().isEmpty() && QString::number( url.port() ).size() > 0
555  && QString( "https://%1:%2" ).arg( url.host() ).arg( url.port() ) == urlbase );
556 }
557 
559 {
560  if ( mDisabled )
561  {
562  return;
563  }
564  bool valid = validateHostPort( txt );
565  leHost->setStyleSheet( valid ? QgsAuthGuiUtils::greenTextStyleSheet()
567  emit hostPortValidityChanged( valid );
568 }
569 
571 {
572  if ( mDisabled )
573  {
574  return;
575  }
576  grpbxSslConfig->setCheckable( checkable );
577  if ( !checkable )
578  {
579  grpbxSslConfig->setEnabled( true );
580  }
581 }
582 
583 void QgsAuthSslConfigWidget::on_btnCertInfo_clicked()
584 {
585  if ( mCert.isNull() )
586  {
587  return;
588  }
589 
590  QgsAuthCertInfoDialog * dlg = new QgsAuthCertInfoDialog( mCert, false, this, mConnectionCAs );
591  dlg->setWindowModality( Qt::WindowModal );
592  dlg->resize( 675, 500 );
593  dlg->exec();
594  dlg->deleteLater();
595 }
596 
597 
599 
601  : QDialog( parent )
602  , mSslConfigWdgt( nullptr )
603 {
604  setWindowTitle( tr( "Custom Certificate Configuration" ) );
605  QVBoxLayout *layout = new QVBoxLayout( this );
606  layout->setMargin( 6 );
607 
608  mSslConfigWdgt = new QgsAuthSslConfigWidget( this, cert, hostport );
609  connect( mSslConfigWdgt, SIGNAL( readyToSaveChanged( bool ) ),
610  this, SLOT( checkCanSave( bool ) ) );
611  layout->addWidget( mSslConfigWdgt );
612 
613  QDialogButtonBox *buttonBox = new QDialogButtonBox(
614  QDialogButtonBox::Close | QDialogButtonBox::Save, Qt::Horizontal, this );
615 
616  buttonBox->button( QDialogButtonBox::Close )->setDefault( true );
617  mSaveButton = buttonBox->button( QDialogButtonBox::Save );
618  connect( buttonBox, SIGNAL( rejected() ), this, SLOT( close() ) );
619  connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
620  layout->addWidget( buttonBox );
621 
622  setLayout( layout );
623  mSaveButton->setEnabled( mSslConfigWdgt->readyToSave() );
624 }
625 
627 {
628 }
629 
631 {
632  mSslConfigWdgt->saveSslCertConfig();
633  QDialog::accept();
634 }
635 
636 void QgsAuthSslConfigDialog::checkCanSave( bool cansave )
637 {
638  mSaveButton->setEnabled( cansave );
639 }
QLayout * layout() const
bool isNull() const
Whether configuration is null (missing components)
void clear()
bool close()
void setMinimum(int min)
void resetSslProtocol()
Reset the SSL protocol to use in connections to the default.
void setupUi(QWidget *widget)
static QgsAuthManager * instance()
Enforce singleton pattern.
QSsl::SslProtocol sslProtocol()
Get the SSL protocl used for connections.
int sslPeerVerifyDepth() const
Number or SSL client&#39;s peer to verify in connections.
bool isNull() const
QTreeWidgetItem * child(int index) const
void setWindowModality(Qt::WindowModality windowModality)
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
void setFont(int column, const QFont &font)
QGroupBox * sslConfigGroupBox()
Access to the SSL configuration&#39;s group box widget.
void rejected()
const T & at(int i) const
QString host() const
Configuration container for SSL server connection exceptions or overrides.
void accepted()
int exec()
void setFirstColumnSpanned(bool span)
virtual void setData(int column, int role, const QVariant &value)
void enableSslCustomOptions(bool enable)
Enable or disable the custom options widget.
void resetSslCertConfig()
Clear the current SSL server configuration and disabled it.
int port() const
QGroupBox * certificateGroupBox()
Access to the certificate&#39;s group box widget.
QSsl::SslProtocol sslProtocol() const
SSL server protocol to use in connections.
QString tr(const char *sourceText, const char *disambiguation, int n)
int sslPeerVerifyDepth()
Get the client&#39;s peer verify depth for connections.
int size() const
QSslSocket::PeerVerifyMode sslPeerVerifyMode() const
SSL client&#39;s peer verify mode to use in connections.
void setSslPeerVerifyMode(QSslSocket::PeerVerifyMode mode)
Set SSL client&#39;s peer verify mode to use in connections.
static void setItemBold_(QTreeWidgetItem *item)
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 addItem(const QString &text, const QVariant &userData)
void setBold(bool enable)
QSize size() const
void setFlags(QFlags< Qt::ItemFlag > flags)
void setSslProtocol(QSsl::SslProtocol protocol)
Set the SSL protocol to use in connections.
bool isEnabled() const
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QString number(int n, int base)
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.
void append(const T &value)
Dialog wrapper for widget displaying detailed info on a certificate and its hierarchical trust chain...
void setLayout(QLayout *layout)
static QString greenTextStyleSheet(const QString &selector="*")
Green text stylesheet representing valid, trusted, etc.
void validateHostPortText(const QString &txt)
Parse string for host:port.
bool isEmpty() const
void configEnabledChanged(bool enabled)
Emitted when the enabled state of the configuration changes.
bool isEmpty() const
const QString sslHost()
Get 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.
QFont font(int column) const
void setSslIgnoreErrors(const QList< QSslError > &errors)
Set 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())
Set SSl certificate and any associated host:port.
const QString sslHostPort() const
Server host:port string.
void deleteLater()
void setMargin(int margin)
virtual void accept()
const QList< QSslError::SslError > sslIgnoredErrorEnums() const
SSL server errors (as enum list) to ignore in connections.
static const QString configFoundText_()
QVariant itemData(int index, int role) const
void setSslHostPort(const QString &hostport)
Set server host:port string.
void setSslIgnoreErrorEnums(const QList< QSslError::SslError > &errorenums)
Set the SSL errors (as enums) to ignore for the connection.
void setConfigCheckable(bool checkable)
Set 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)
Set the client&#39;s peer verify mode for connections.
bool contains(const T &value) const
void setSslProtocol(QSsl::SslProtocol protocol)
Set SSL server protocol to use in connections.
void setMaximum(int max)
static QString shaHexForCert(const QSslCertificate &cert, bool formatted=false)
Get the sha1 hash for certificate.
void hostPortValidityChanged(bool valid)
Emitted when the validity of the host:port changes.
void setAlignment(QFlags< Qt::AlignmentFlag > flag)
void resetSslIgnoreErrors()
Clear the SSL errors to ignore for the connection.
static QString redTextStyleSheet(const QString &selector="*")
Red text stylesheet representing invalid, untrusted, etc.
void setExpanded(bool expand)
bool readyToSave()
Verify if the configuration if ready to save.
void setCheckState(int column, Qt::CheckState state)
const QSslCertificate sslCertificate() const
Server certificate object.
void loadSslCustomConfig(const QgsAuthConfigSslServer &config=QgsAuthConfigSslServer())
Load an existing SSL server configuration.
Qt::ItemFlags flags() const
void setMaximumWidth(int maxw)
int findData(const QVariant &data, int role, QFlags< Qt::MatchFlag > flags) const
void setSslIgnoredErrorEnums(const QList< QSslError::SslError > &errors)
Set SSL server errors (as enum list) to ignore in connections.
void setSslHost(const QString &host)
Set the host of the server.
void setWindowTitle(const QString &)
const QSslCertificate sslCertificate()
Get the SSL server certificate.
void setCurrentIndex(int index)
SslError error() const
void readyToSaveChanged(bool cansave)
Emitted when the configuration can be saved changes.
QSslSocket::PeerVerifyMode sslPeerVerifyMode()
Get the client&#39;s peer verify mode for connections.
QPushButton * button(StandardButton which) const
void setTextAlignment(int column, int alignment)
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.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const
void accept() override
Overridden base dialog accept slot.
static QList< QPair< QSslError::SslError, QString > > sslErrorEnumStrings()
Get short strings describing SSL errors.
void setSslCertificate(const QSslCertificate &cert)
Set server certificate object.
int childCount() const
void setDefault(bool)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
static QString resolvedCertName(const QSslCertificate &cert, bool issuer=false)
Get the general name via RFC 5280 resolution.
const QgsAuthConfigSslServer sslCustomConfig()
Get 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()
Get list of the SSL errors (as enums) to be ignored for connections.
static const QString configNotFoundText_()