19#include "moc_qgsauthcertificateinfo.cpp"
20#include "ui_qgsauthcertificateinfo.h"
23#include <QDialogButtonBox>
25#include <QPlainTextEdit>
37 , mConnectionCAs( connectionCAs )
38 , mDefaultItemForeground( QBrush() )
39 , mManageTrust( manageCertTrust )
40 , mTrustCacheRebuilt( false )
47 mAuthNotifyLayout =
new QVBoxLayout;
48 this->setLayout( mAuthNotifyLayout );
50 mAuthNotifyLayout->addWidget( mAuthNotify );
55 connect( btnSaveTrust, &QToolButton::clicked,
this, &QgsAuthCertInfo::btnSaveTrust_clicked );
57 lblError->setHidden(
true );
59 treeHierarchy->setRootIsDecorated(
false );
61 connect( treeHierarchy, &QTreeWidget::currentItemChanged,
this, &QgsAuthCertInfo::currentCertItemChanged );
65 setUpCertDetailsTree();
67 grpbxTrust->setVisible( mManageTrust );
74 res = populateQcaCertCollection();
76 res = setQcaCertificate( cert );
78 res = populateCertChain();
82 connect( cmbbxTrust,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsAuthCertInfo::currentPolicyIndexChanged );
86void QgsAuthCertInfo::setupError(
const QString &msg )
88 lblError->setVisible(
true );
89 QString out = tr(
"<b>Setup ERROR:</b>\n\n" );
91 lblError->setText( out );
95void QgsAuthCertInfo::currentCertItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *previous )
98 updateCurrentCert( current );
101void QgsAuthCertInfo::updateCurrentCert( QTreeWidgetItem *item )
104 item = treeHierarchy->currentItem();
108 const int indx( item->data( 0, Qt::UserRole ).toInt() );
109 updateCurrentCertInfo( indx );
112bool QgsAuthCertInfo::populateQcaCertCollection()
114 const QList<QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate>> &certpairs( mCaCertsCache.values() );
115 for (
int i = 0; i < certpairs.size(); ++i )
117 QCA::ConvertResult res;
118 const QCA::Certificate acert = QCA::Certificate::fromPEM( certpairs.at( i ).second.toPem(), &res, QStringLiteral(
"qca-ossl" ) );
119 if ( res == QCA::ConvertGood && !acert.isNull() )
121 mCaCerts.addCertificate( acert );
124 if ( !mConnectionCAs.isEmpty() )
126 const auto constMConnectionCAs = mConnectionCAs;
127 for (
const QSslCertificate &cert : constMConnectionCAs )
129 QCA::ConvertResult res;
130 const QCA::Certificate acert = QCA::Certificate::fromPEM( cert.toPem(), &res, QStringLiteral(
"qca-ossl" ) );
131 if ( res == QCA::ConvertGood && !acert.isNull() )
133 mCaCerts.addCertificate( acert );
138 if ( mCaCerts.certificates().empty() )
140 setupError( tr(
"Could not populate QCA certificate collection" ) );
146bool QgsAuthCertInfo::setQcaCertificate(
const QSslCertificate &cert )
148 QCA::ConvertResult res;
149 mCert = QCA::Certificate::fromPEM( cert.toPem(), &res, QStringLiteral(
"qca-ossl" ) );
150 if ( res != QCA::ConvertGood || mCert.isNull() )
152 setupError( tr(
"Could not set QCA certificate" ) );
158bool QgsAuthCertInfo::populateCertChain()
160 const QCA::CertificateChain certchain( mCert );
162 mACertChain = certchain.complete( mCaCerts.certificates(), &valid );
163 if ( valid != QCA::ValidityGood && valid != QCA::ErrorInvalidCA )
166 setupError( tr(
"Invalid population of QCA certificate chain.<br><br>"
167 "Validity message: %1" )
172 if ( mACertChain.isEmpty() )
174 QgsDebugError( QStringLiteral(
"Could not populate QCA certificate chain" ) );
175 mACertChain = certchain;
178 if ( !mACertChain.last().isSelfSigned() )
181 mACertChain.append( QCA::Certificate() );
185 const auto constMACertChain = mACertChain;
186 for (
const QCA::Certificate &cert : constMACertChain )
188 QSslCertificate qcert;
189 if ( !cert.isNull() )
191 qcert = QSslCertificate( cert.toPEM().toLatin1() );
193 mQCertChain.append( qcert );
198void QgsAuthCertInfo::setCertHierarchy()
200 QListIterator<QSslCertificate> it( mQCertChain );
202 int i = mQCertChain.size();
203 QTreeWidgetItem *item =
nullptr;
204 QTreeWidgetItem *previtem =
nullptr;
205 while ( it.hasPrevious() )
207 const QSslCertificate cert( it.previous() );
208 const bool missingCA = cert.isNull();
210 if ( missingCA && it.hasPrevious() )
213 cert_source += QStringLiteral(
" (%1)" ).arg( tr(
"Missing CA" ) );
219 if ( mCaCertsCache.contains( sha ) )
221 const QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate> &certpair( mCaCertsCache.value( sha ) );
224 else if ( mConnectionCAs.contains( cert ) )
226 cert_source += QStringLiteral(
" (%1)" )
233 item =
new QTreeWidgetItem( treeHierarchy, QStringList() << cert_source );
237 item =
new QTreeWidgetItem( previtem, QStringList() << cert_source );
239 if ( missingCA && it.hasPrevious() )
241 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
244 item->setData( 0, Qt::UserRole, --i );
246 if ( mDefaultItemForeground.style() == Qt::NoBrush )
248 mDefaultItemForeground = item->foreground( 0 );
253 item->setFirstColumnSpanned(
true );
255 treeHierarchy->addTopLevelItem( item );
258 treeHierarchy->setCurrentItem( item, 0, QItemSelectionModel::ClearAndSelect );
259 treeHierarchy->expandAll();
262void QgsAuthCertInfo::updateCurrentCertInfo(
int chainindx )
264 btnSaveTrust->setEnabled(
false );
266 mCurrentQCert = mQCertChain.at( chainindx );
267 mCurrentACert = mACertChain.at( chainindx );
271 grpbxTrust->setHidden( mCurrentQCert.isNull() );
274 if ( !mCurrentQCert.isNull() )
277 mCurrentTrustPolicy = trustpolicy;
279 cmbbxTrust->setTrustPolicy( trustpolicy );
289void QgsAuthCertInfo::setUpCertDetailsTree()
291 treeDetails->setColumnCount( 2 );
292 treeDetails->setHeaderLabels( QStringList() << tr(
"Field" ) << tr(
"Value" ) );
293 treeDetails->setColumnWidth( 0, 200 );
295 QTreeWidgetItem *headeritem = treeDetails->headerItem();
296 headeritem->setTextAlignment( 0, Qt::AlignRight );
297 headeritem->setTextAlignment( 1, Qt::AlignLeft );
299 treeDetails->setRootIsDecorated(
true );
300 treeDetails->setWordWrap(
true );
303 mSecGeneral =
new QTreeWidgetItem(
305 QStringList( tr(
"General" ) ),
306 static_cast<int>( DetailsSection )
309 mSecGeneral->setFirstColumnSpanned(
true );
310 mSecGeneral->setFlags( Qt::ItemIsEnabled );
311 mSecGeneral->setExpanded(
true );
312 treeDetails->insertTopLevelItem( 0, mSecGeneral );
314 mSecDetails =
new QTreeWidgetItem(
316 QStringList( tr(
"Details" ) ),
317 static_cast<int>( DetailsSection )
320 mSecDetails->setFirstColumnSpanned(
true );
321 mSecDetails->setFlags( Qt::ItemIsEnabled );
322 mSecDetails->setExpanded(
false );
323 treeDetails->insertTopLevelItem( 0, mSecDetails );
326 mGrpSubj = addGroupItem( mSecDetails, tr(
"Subject Info" ) );
327 mGrpIssu = addGroupItem( mSecDetails, tr(
"Issuer Info" ) );
328 mGrpCert = addGroupItem( mSecDetails, tr(
"Certificate Info" ) );
329 mGrpPkey = addGroupItem( mSecDetails, tr(
"Public Key Info" ) );
330 mGrpExts = addGroupItem( mSecDetails, tr(
"Extensions" ) );
332 mSecPemText =
new QTreeWidgetItem(
334 QStringList( tr(
"PEM Text" ) ),
335 static_cast<int>( DetailsSection )
338 mSecPemText->setFirstColumnSpanned(
true );
339 mSecPemText->setFlags( Qt::ItemIsEnabled );
340 mSecPemText->setExpanded(
false );
341 treeDetails->insertTopLevelItem( 0, mSecPemText );
344void QgsAuthCertInfo::populateCertInfo()
346 mSecDetails->setHidden(
false );
347 mSecPemText->setHidden(
false );
349 populateInfoGeneralSection();
350 populateInfoDetailsSection();
351 populateInfoPemTextSection();
354QTreeWidgetItem *QgsAuthCertInfo::addGroupItem( QTreeWidgetItem *parent,
const QString &group )
356 QTreeWidgetItem *grpitem =
new QTreeWidgetItem(
358 QStringList( group ),
359 static_cast<int>( DetailsGroup )
362 grpitem->setFirstColumnSpanned(
true );
363 grpitem->setFlags( Qt::ItemIsEnabled );
364 grpitem->setExpanded(
true );
366 QBrush orgb( grpitem->foreground( 0 ) );
367 orgb.setColor( QColor::fromRgb( 90, 90, 90 ) );
368 grpitem->setForeground( 0, orgb );
369 QFont grpf( grpitem->font( 0 ) );
370 grpf.setItalic(
true );
371 grpitem->setFont( 0, grpf );
376void QgsAuthCertInfo::addFieldItem( QTreeWidgetItem *parent,
const QString &field,
const QString &value, QgsAuthCertInfo::FieldWidget wdgt,
const QColor &color )
378 if ( value.isEmpty() )
381 QTreeWidgetItem *item =
new QTreeWidgetItem(
383 QStringList() << field << ( wdgt == NoWidget ? value : QString() ),
384 static_cast<int>( DetailsField )
387 item->setTextAlignment( 0, Qt::AlignRight );
388 item->setTextAlignment( 1, Qt::AlignLeft );
390 QBrush fieldb( item->foreground( 0 ) );
391 fieldb.setColor( QColor::fromRgb( 90, 90, 90 ) );
392 item->setForeground( 0, fieldb );
394 if ( wdgt == NoWidget )
396 if ( color.isValid() )
398 QBrush valueb( item->foreground( 1 ) );
399 valueb.setColor( color );
400 item->setForeground( 1, valueb );
403 else if ( wdgt == LineEdit )
405 QLineEdit *le =
new QLineEdit( value, treeDetails );
406 le->setReadOnly(
true );
407 le->setAlignment( Qt::AlignLeft );
408 le->setCursorPosition( 0 );
409 if ( color.isValid() )
411 le->setStyleSheet( QStringLiteral(
"QLineEdit { color: %1; }" ).arg( color.name() ) );
413 item->treeWidget()->setItemWidget( item, 1, le );
415 else if ( wdgt == TextEdit )
417 QPlainTextEdit *pte =
new QPlainTextEdit( value, treeDetails );
418 pte->setReadOnly(
true );
419 pte->setMinimumHeight( 75 );
420 pte->setMaximumHeight( 75 );
421 pte->moveCursor( QTextCursor::Start );
422 if ( color.isValid() )
424 pte->setStyleSheet( QStringLiteral(
"QPlainTextEdit { color: %1; }" ).arg( color.name() ) );
426 item->treeWidget()->setItemWidget( item, 1, pte );
430void QgsAuthCertInfo::populateInfoGeneralSection()
434 if ( mCurrentQCert.isNull() )
436 addFieldItem( mSecGeneral, tr(
"Type" ), tr(
"Missing CA (incomplete local CA chain)" ), LineEdit );
437 mSecGeneral->setExpanded(
true );
438 mSecDetails->setHidden(
true );
439 mSecPemText->setHidden(
true );
444 const bool isselfsigned = mCurrentACert.isSelfSigned();
445 const QString selfsigned( tr(
"self-signed" ) );
447 const QList<QgsAuthCertUtils::CertUsageType> usagetypes(
463 if ( isissuer || ( isca && !isselfsigned ) )
467 if ( ( isissuer || isca ) && isselfsigned )
469 certype = QStringLiteral(
"%1 %2" )
474 certype.append( certype.isEmpty() ? selfsigned : QStringLiteral(
" (%1)" ).arg( selfsigned ) );
477 addFieldItem( mSecGeneral, tr(
"Usage type" ), certype, LineEdit );
480 addFieldItem( mSecGeneral, tr(
"Not valid after" ), mCurrentQCert.expiryDate().toString(), LineEdit, mCurrentQCert.expiryDate() < QDateTime::currentDateTime() ?
QgsAuthGuiUtils::redColor() : QColor() );
482 const QSslKey pubkey( mCurrentQCert.publicKey() );
483 const QString alg( pubkey.algorithm() == QSsl::Rsa ?
"RSA" :
"DSA" );
484 const int bitsize( pubkey.length() );
485 addFieldItem( mSecGeneral, tr(
"Public key" ), QStringLiteral(
"%1, %2 bits" ).arg( alg, bitsize == -1 ? QStringLiteral(
"?" ) : QString::number( bitsize ) ), LineEdit );
489void QgsAuthCertInfo::populateInfoDetailsSection()
497 if ( mCurrentQCert.isNull() )
501 addFieldItem( mGrpSubj, tr(
"Country (C)" ),
SSL_SUBJECT_INFO( mCurrentQCert, QSslCertificate::CountryName ), LineEdit );
502 addFieldItem( mGrpSubj, tr(
"State/Province (ST)" ),
SSL_SUBJECT_INFO( mCurrentQCert, QSslCertificate::StateOrProvinceName ), LineEdit );
503 addFieldItem( mGrpSubj, tr(
"Locality (L)" ),
SSL_SUBJECT_INFO( mCurrentQCert, QSslCertificate::LocalityName ), LineEdit );
504 addFieldItem( mGrpSubj, tr(
"Organization (O)" ),
SSL_SUBJECT_INFO( mCurrentQCert, QSslCertificate::Organization ), LineEdit );
505 addFieldItem( mGrpSubj, tr(
"Organizational unit (OU)" ),
SSL_SUBJECT_INFO( mCurrentQCert, QSslCertificate::OrganizationalUnitName ), LineEdit );
506 addFieldItem( mGrpSubj, tr(
"Common name (CN)" ),
SSL_SUBJECT_INFO( mCurrentQCert, QSslCertificate::CommonName ), LineEdit );
507 addFieldItem( mGrpSubj, tr(
"Email address (E)" ), mCurrentACert.subjectInfo().value( QCA::Email ), LineEdit );
509 addFieldItem( mGrpSubj, tr(
"Email Legacy" ), mCurrentACert.subjectInfo().value( QCA::EmailLegacy ), LineEdit );
510 addFieldItem( mGrpSubj, tr(
"Incorporation Country" ), mCurrentACert.subjectInfo().value( QCA::IncorporationCountry ), LineEdit );
511 addFieldItem( mGrpSubj, tr(
"Incorporation State/Province" ), mCurrentACert.subjectInfo().value( QCA::IncorporationState ), LineEdit );
512 addFieldItem( mGrpSubj, tr(
"Incorporation Locality" ), mCurrentACert.subjectInfo().value( QCA::IncorporationLocality ), LineEdit );
513 addFieldItem( mGrpSubj, tr(
"URI" ), mCurrentACert.subjectInfo().value( QCA::URI ), LineEdit );
514 addFieldItem( mGrpSubj, tr(
"DNS" ), mCurrentACert.subjectInfo().value( QCA::DNS ), LineEdit );
515 addFieldItem( mGrpSubj, tr(
"IP Address" ), mCurrentACert.subjectInfo().value( QCA::IPAddress ), LineEdit );
516 addFieldItem( mGrpSubj, tr(
"XMPP" ), mCurrentACert.subjectInfo().value( QCA::XMPP ), LineEdit );
518 const QMultiMap<QSsl::AlternativeNameEntryType, QString> alts( mCurrentQCert.subjectAlternativeNames() );
519 QStringList altslist;
520 const QString email( tr(
"Email: " ) );
521 const QStringList emails( alts.values( QSsl::EmailEntry ) );
522 if ( !emails.isEmpty() )
524 altslist << email + emails.join(
'\n' + email );
526 const QString dns( tr(
"DNS: " ) );
527 const QStringList dnss( alts.values( QSsl::DnsEntry ) );
528 if ( !dnss.isEmpty() )
530 altslist << dns + dnss.join(
'\n' + dns );
532 addFieldItem( mGrpSubj, tr(
"Alternate names" ), altslist.join( QLatin1Char(
'\n' ) ), TextEdit );
535 addFieldItem( mGrpIssu, tr(
"Country (C)" ),
SSL_ISSUER_INFO( mCurrentQCert, QSslCertificate::CountryName ), LineEdit );
536 addFieldItem( mGrpIssu, tr(
"State/Province (ST)" ),
SSL_ISSUER_INFO( mCurrentQCert, QSslCertificate::StateOrProvinceName ), LineEdit );
537 addFieldItem( mGrpIssu, tr(
"Locality (L)" ),
SSL_ISSUER_INFO( mCurrentQCert, QSslCertificate::LocalityName ), LineEdit );
538 addFieldItem( mGrpIssu, tr(
"Organization (O)" ),
SSL_ISSUER_INFO( mCurrentQCert, QSslCertificate::Organization ), LineEdit );
539 addFieldItem( mGrpIssu, tr(
"Organizational unit (OU)" ),
SSL_ISSUER_INFO( mCurrentQCert, QSslCertificate::OrganizationalUnitName ), LineEdit );
540 addFieldItem( mGrpIssu, tr(
"Common name (CN)" ),
SSL_ISSUER_INFO( mCurrentQCert, QSslCertificate::CommonName ), LineEdit );
541 addFieldItem( mGrpIssu, tr(
"Email address (E)" ), mCurrentACert.issuerInfo().value( QCA::Email ), LineEdit );
543 addFieldItem( mGrpIssu, tr(
"Email Legacy" ), mCurrentACert.issuerInfo().value( QCA::EmailLegacy ), LineEdit );
544 addFieldItem( mGrpIssu, tr(
"Incorporation Country" ), mCurrentACert.issuerInfo().value( QCA::IncorporationCountry ), LineEdit );
545 addFieldItem( mGrpIssu, tr(
"Incorporation State/Province" ), mCurrentACert.issuerInfo().value( QCA::IncorporationState ), LineEdit );
546 addFieldItem( mGrpIssu, tr(
"Incorporation Locality" ), mCurrentACert.issuerInfo().value( QCA::IncorporationLocality ), LineEdit );
547 addFieldItem( mGrpIssu, tr(
"URI" ), mCurrentACert.issuerInfo().value( QCA::URI ), LineEdit );
548 addFieldItem( mGrpIssu, tr(
"DNS" ), mCurrentACert.issuerInfo().value( QCA::DNS ), LineEdit );
549 addFieldItem( mGrpIssu, tr(
"IP Address" ), mCurrentACert.issuerInfo().value( QCA::IPAddress ), LineEdit );
550 addFieldItem( mGrpIssu, tr(
"XMPP" ), mCurrentACert.issuerInfo().value( QCA::XMPP ), LineEdit );
553 addFieldItem( mGrpCert, tr(
"Version" ), mCurrentQCert.version(), LineEdit );
554 addFieldItem( mGrpCert, tr(
"Serial #" ), mCurrentQCert.serialNumber(), LineEdit );
555 addFieldItem( mGrpCert, tr(
"Not valid before" ), mCurrentQCert.effectiveDate().toString(), LineEdit, mCurrentQCert.effectiveDate() > QDateTime::currentDateTime() ?
QgsAuthGuiUtils::redColor() : QColor() );
556 addFieldItem( mGrpCert, tr(
"Not valid after" ), mCurrentQCert.expiryDate().toString(), LineEdit, mCurrentQCert.expiryDate() < QDateTime::currentDateTime() ?
QgsAuthGuiUtils::redColor() : QColor() );
561 const QStringList crllocs( mCurrentACert.crlLocations() );
562 if ( !crllocs.isEmpty() )
564 addFieldItem( mGrpCert, tr(
"CRL locations" ), crllocs.join( QLatin1Char(
'\n' ) ), TextEdit );
566 const QStringList issulocs( mCurrentACert.issuerLocations() );
567 if ( !issulocs.isEmpty() )
569 addFieldItem( mGrpCert, tr(
"Issuer locations" ), issulocs.join( QLatin1Char(
'\n' ) ), TextEdit );
571 const QStringList ocsplocs( mCurrentACert.ocspLocations() );
572 if ( !ocsplocs.isEmpty() )
574 addFieldItem( mGrpCert, tr(
"OCSP locations" ), ocsplocs.join( QLatin1Char(
'\n' ) ), TextEdit );
579 const QSslKey pubqkey( mCurrentQCert.publicKey() );
580 const QString alg( pubqkey.algorithm() == QSsl::Rsa ?
"RSA" :
"DSA" );
581 const int bitsize( pubqkey.length() );
582 addFieldItem( mGrpPkey, tr(
"Algorithm" ), bitsize == -1 ? QStringLiteral(
"Unknown (possibly Elliptic Curve)" ) : alg, LineEdit );
583 addFieldItem( mGrpPkey, tr(
"Key size" ), bitsize == -1 ? QStringLiteral(
"?" ) : QString::number( bitsize ), LineEdit );
586 const QCA::PublicKey pubakey( mCurrentACert.subjectPublicKey() );
588 if ( pubqkey.algorithm() == QSsl::Rsa )
590 const QCA::RSAPublicKey rsakey( pubakey.toRSA() );
591 const QCA::BigInteger modulus = rsakey.n();
592 QByteArray modarray( modulus.toArray().toByteArray().toHex() );
593 if ( modarray.size() > 2 && modarray.mid( 0, 2 ) == QByteArray(
"00" ) )
595 modarray = modarray.mid( 2 );
597 const QCA::BigInteger exponent = rsakey.e();
599 addFieldItem( mGrpPkey, tr(
"Exponent" ), exponent.toString(), LineEdit );
611 if ( pubakey.canVerify() )
613 usage.append( tr(
"Verify" ) );
617 if ( pubakey.canEncrypt() )
619 usage.append( tr(
"Encrypt" ) );
621#if QCA_VERSION >= 0x020100
622 if ( pubakey.canDecrypt() )
624 usage.append( tr(
"Decrypt" ) );
627 if ( pubakey.canKeyAgree() )
629 usage.append( tr(
"Key agreement" ) );
631 if ( pubakey.canExport() )
633 usage.append( tr(
"Export" ) );
635 if ( !usage.isEmpty() )
637 addFieldItem( mGrpPkey, tr(
"Key usage" ), usage.join( QLatin1String(
", " ) ), LineEdit );
642 QStringList basicconst;
643 basicconst << tr(
"Certificate Authority: %1" ).arg( mCurrentACert.isCA() ? tr(
"Yes" ) : tr(
"No" ) )
644 << tr(
"Chain Path Limit: %1" ).arg( mCurrentACert.pathLimit() );
645 addFieldItem( mGrpExts, tr(
"Basic constraints" ), basicconst.join( QLatin1Char(
'\n' ) ), TextEdit );
647 QStringList keyusage;
648 QStringList extkeyusage;
649 const QList<QCA::ConstraintType> certconsts = mCurrentACert.constraints();
650 const auto constCertconsts = certconsts;
651 for (
const QCA::ConstraintType &certconst : constCertconsts )
653 if ( certconst.section() == QCA::ConstraintType::KeyUsage )
657 else if ( certconst.section() == QCA::ConstraintType::ExtendedKeyUsage )
662 if ( !keyusage.isEmpty() )
664 addFieldItem( mGrpExts, tr(
"Key usage" ), keyusage.join( QLatin1Char(
'\n' ) ), TextEdit );
666 if ( !extkeyusage.isEmpty() )
668 addFieldItem( mGrpExts, tr(
"Extended key usage" ), extkeyusage.join( QLatin1Char(
'\n' ) ), TextEdit );
675void QgsAuthCertInfo::populateInfoPemTextSection()
679 if ( mCurrentQCert.isNull() )
682 QTreeWidgetItem *item =
new QTreeWidgetItem(
684 QStringList( QString() ),
685 static_cast<int>( DetailsField )
688 item->setFirstColumnSpanned(
true );
690 QPlainTextEdit *pte =
new QPlainTextEdit( mCurrentQCert.toPem(), treeDetails );
691 pte->setReadOnly(
true );
692 pte->setMinimumHeight( 150 );
693 pte->setMaximumHeight( 150 );
694 pte->moveCursor( QTextCursor::Start );
695 item->treeWidget()->setItemWidget( item, 0, pte );
698void QgsAuthCertInfo::btnSaveTrust_clicked()
703 QgsDebugError( QStringLiteral(
"Could not set trust policy for certificate" ) );
705 mCurrentTrustPolicy = newpolicy;
706 decorateCertTreeItem( mCurrentQCert, newpolicy,
nullptr );
707 btnSaveTrust->setEnabled(
false );
711 mTrustCacheRebuilt =
true;
715void QgsAuthCertInfo::currentPolicyIndexChanged(
int indx )
718 btnSaveTrust->setEnabled( newpolicy != mCurrentTrustPolicy );
725 item = treeHierarchy->currentItem();
736 QBrush b( item->foreground( 0 ) );
737 b.setColor( QColor::fromRgb( 90, 90, 90 ) );
738 item->setForeground( 0, b );
739 QFont f( item->font( 0 ) );
741 item->setFont( 0, f );
772 setWindowTitle( tr(
"Certificate Information" ) );
773 QVBoxLayout *layout =
new QVBoxLayout(
this );
774 layout->setContentsMargins( 6, 6, 6, 6 );
776 mCertInfoWdgt =
new QgsAuthCertInfo( cert, manageCertTrust,
this, connectionCAs );
777 layout->addWidget( mCertInfoWdgt );
779 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Close, Qt::Horizontal,
this );
780 buttonBox->button( QDialogButtonBox::Close )->setDefault(
true );
781 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QWidget::close );
782 layout->addWidget( buttonBox );
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
QgsAuthCertInfoDialog(const QSslCertificate &cert, bool manageCertTrust, QWidget *parent=nullptr, const QList< QSslCertificate > &connectionCAs=QList< QSslCertificate >())
Construct a dialog displaying detailed info on a certificate and its hierarchical trust chain.
Widget for viewing detailed info on a certificate and its hierarchical trust chain.
QgsAuthCertInfo(const QSslCertificate &cert, bool manageCertTrust=false, QWidget *parent=nullptr, const QList< QSslCertificate > &connectionCAs=QList< QSslCertificate >())
Constructor for QgsAuthCertInfo.
Utilities for working with certificates and keys.
static QString qcaValidityMessage(QCA::Validity validity)
Certificate validity check messages per enum.
static QList< QgsAuthCertUtils::CertUsageType > certificateUsageTypes(const QSslCertificate &cert)
Try to determine the certificates usage types.
static QString qcaSignatureAlgorithm(QCA::SignatureAlgorithm algorithm)
Certificate signature algorithm strings per enum.
static QString resolvedCertName(const QSslCertificate &cert, bool issuer=false)
Gets the general name via RFC 5280 resolution.
static QString certificateUsageTypeString(QgsAuthCertUtils::CertUsageType usagetype)
Certificate usage type strings per enum.
static QString shaHexForCert(const QSslCertificate &cert, bool formatted=false)
Gets the sha1 hash for certificate.
CertTrustPolicy
Type of certificate trust policy.
static QString qcaKnownConstraint(QCA::ConstraintTypeKnown constraint)
Certificate well-known constraint strings per enum.
static bool certIsViable(const QSslCertificate &cert)
certIsViable checks for viability errors of cert and whether it is NULL
static QString getColonDelimited(const QString &txt)
Gets string with colon delimiters every 2 characters.
static QString getCaSourceName(QgsAuthCertUtils::CaCertSource source, bool single=false)
Gets the general name for CA source enum type.
static QString getCertDistinguishedName(const QSslCertificate &qcert, const QCA::Certificate &acert=QCA::Certificate(), bool issuer=false)
Gets combined distinguished name for certificate.
static QString redTextStyleSheet(const QString &selector="*")
Red text stylesheet representing invalid, untrusted, etc. certificate.
static void setItemBold(QTreeWidgetItem *item)
Call setFirstColumnSpanned(true) on the item and make its font bold.
static void removeChildren(QTreeWidgetItem *item)
Remove the children of the passed item.
static QColor redColor()
Red color representing invalid, untrusted, etc. certificate.
QgsAuthCertUtils::CertTrustPolicy defaultCertTrustPolicy()
Gets the default certificate trust policy preferred by user.
bool rebuildCertTrustCache()
Rebuild certificate authority cache.
const QMap< QString, QPair< QgsAuthCertUtils::CaCertSource, QSslCertificate > > caCertsCache()
caCertsCache get all CA certs mapped to their sha1 from cache.
bool rebuildTrustedCaCertsCache()
Rebuild trusted certificate authorities cache.
#define SSL_SUBJECT_INFO(var, prop)
#define SSL_ISSUER_INFO(var, prop)
#define QgsDebugError(str)