mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-09 00:35:20 -05:00
Merge pull request #5480 from boundlessgeo/auth_get_removal
[api][auth] Removed get prefix from all getters in auth manager
This commit is contained in:
commit
8ef715be15
@ -539,6 +539,30 @@ QgsAuthManager {#qgis_api_break_3_0_QgsAuthManager}
|
||||
- scheduledAuthDbErase() was renamed to scheduledAuthDatabaseErase()
|
||||
- setScheduledAuthDbErase() was renamed to setScheduledAuthDatabaseErase()
|
||||
- setScheduledAuthDbEraseRequestEmitted() was renamed to setScheduledAuthDatabaseEraseRequestEmitted()
|
||||
- getAuthSetting() was renamed to authSetting()
|
||||
- getCertIdentity() was renamed to certIdentity()
|
||||
- getCertIdentityBundle() was renamed to certIdentityBundle()
|
||||
- getCertIdentityBundleToPem() was renamed to certIdentityBundleToPem()
|
||||
- getCertIdentities() was renamed to certIdentities()
|
||||
- getCertIdentityIds() was renamed to certIdentityIds()
|
||||
- getSslCertCustomConfig() was renamed to sslCertCustomConfig()
|
||||
- getSslCertCustomConfigByHost() was renamed to sslCertCustomConfigByHost()
|
||||
- getSslCertCustomConfigs() was renamed to sslCertCustomConfigs()
|
||||
- getIgnoredSslErrorCache() was renamed to ignoredSslErrorCache()
|
||||
- getCertAuthority() was renamed to certAuthority()
|
||||
- getSystemRootCAs() was renamed to systemRootCAs()
|
||||
- getExtraFileCAs() was renamed to extraFileCAs()
|
||||
- getDatabaseCAs() was renamed to databaseCAs()
|
||||
- getMappedDatabaseCAs() was renamed to mappedDatabaseCAs()
|
||||
- getCaCertsCache() was renamed to caCertsCache()
|
||||
- getCertTrustPolicy() was renamed to certTrustPolicy()
|
||||
- getCertificateTrustPolicy() was renamed to certificateTrustPolicy()
|
||||
- getCertTrustCache() was renamed to certTrustCache()
|
||||
- getTrustedCaCerts() was renamed to trustedCaCerts()
|
||||
- getUntrustedCaCerts() was renamed to untrustedCaCerts()
|
||||
- getTrustedCaCertsCache() was renamed to trustedCaCertsCache()
|
||||
- getTrustedCaCertsPemText() was renamed to trustedCaCertsPemText()
|
||||
|
||||
|
||||
|
||||
QgsAuthMethod {#qgis_api_break_3_0_QgsAuthMethod}
|
||||
|
@ -374,9 +374,14 @@ Store an authentication setting (stored as string via QVariant( value ).toString
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QVariant getAuthSetting( const QString &key, const QVariant &defaultValue = QVariant(), bool decrypt = false );
|
||||
QVariant authSetting( const QString &key, const QVariant &defaultValue = QVariant(), bool decrypt = false );
|
||||
%Docstring
|
||||
Get an authentication setting (retrieved as string and returned as QVariant( QString ))
|
||||
authSetting get an authentication setting (retrieved as string and returned as QVariant( QString ))
|
||||
\param key setting key
|
||||
\param defaultValue
|
||||
\param decrypt if the value needs decrypted
|
||||
:return: QVariant( QString ) authentication setting
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QVariant
|
||||
%End
|
||||
|
||||
@ -405,28 +410,39 @@ Store a certificate identity
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
const QSslCertificate getCertIdentity( const QString &id );
|
||||
const QSslCertificate certIdentity( const QString &id );
|
||||
%Docstring
|
||||
Get a certificate identity by id (sha hash)
|
||||
certIdentity get a certificate identity by ``id`` (sha hash)
|
||||
\param id sha hash of the cert
|
||||
:return: the certificate
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QSslCertificate
|
||||
%End
|
||||
|
||||
|
||||
const QStringList getCertIdentityBundleToPem( const QString &id );
|
||||
const QStringList certIdentityBundleToPem( const QString &id );
|
||||
%Docstring
|
||||
Get a certificate identity bundle by id (sha hash) returned as PEM text
|
||||
certIdentityBundleToPem get a certificate identity bundle by ``id`` (sha hash) returned as PEM text
|
||||
\param id sha hash
|
||||
:return: a list of strings
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of str
|
||||
%End
|
||||
|
||||
const QList<QSslCertificate> getCertIdentities();
|
||||
const QList<QSslCertificate> certIdentities();
|
||||
%Docstring
|
||||
Get certificate identities
|
||||
certIdentities get certificate identities
|
||||
:return: list of certificates
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of QSslCertificate
|
||||
%End
|
||||
|
||||
QStringList getCertIdentityIds() const;
|
||||
|
||||
QStringList certIdentityIds() const;
|
||||
%Docstring
|
||||
Get list of certificate identity ids from database
|
||||
certIdentityIds get list of certificate identity ids from database
|
||||
:return: list of certificate ids
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of str
|
||||
%End
|
||||
|
||||
@ -449,21 +465,30 @@ Store an SSL certificate custom config
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
const QgsAuthConfigSslServer getSslCertCustomConfig( const QString &id, const QString &hostport );
|
||||
const QgsAuthConfigSslServer sslCertCustomConfig( const QString &id, const QString &hostport );
|
||||
%Docstring
|
||||
Get an SSL certificate custom config by id (sha hash) and host:port
|
||||
sslCertCustomConfig get an SSL certificate custom config by ``id`` (sha hash) and ``hostport`` (host:port)
|
||||
\param id sha hash
|
||||
\param hostport string host:port
|
||||
:return: a SSL certificate custom config
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsAuthConfigSslServer
|
||||
%End
|
||||
|
||||
const QgsAuthConfigSslServer getSslCertCustomConfigByHost( const QString &hostport );
|
||||
const QgsAuthConfigSslServer sslCertCustomConfigByHost( const QString &hostport );
|
||||
%Docstring
|
||||
Get an SSL certificate custom config by host:port
|
||||
sslCertCustomConfigByHost get an SSL certificate custom config by ``hostport`` (host:port)
|
||||
\param hostport host:port
|
||||
:return: a SSL certificate custom config
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsAuthConfigSslServer
|
||||
%End
|
||||
|
||||
const QList<QgsAuthConfigSslServer> getSslCertCustomConfigs();
|
||||
const QList<QgsAuthConfigSslServer> sslCertCustomConfigs();
|
||||
%Docstring
|
||||
Get SSL certificate custom configs
|
||||
sslCertCustomConfigs get SSL certificate custom configs
|
||||
:return: list of SSL certificate custom config
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of QgsAuthConfigSslServer
|
||||
%End
|
||||
|
||||
@ -516,9 +541,13 @@ Store a certificate authority
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
const QSslCertificate getCertAuthority( const QString &id );
|
||||
|
||||
const QSslCertificate certAuthority( const QString &id );
|
||||
%Docstring
|
||||
Get a certificate authority by id (sha hash)
|
||||
certAuthority get a certificate authority by ``id`` (sha hash)
|
||||
\param id sha hash
|
||||
:return: a certificate
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QSslCertificate
|
||||
%End
|
||||
|
||||
@ -534,27 +563,35 @@ Remove a certificate authority
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
const QList<QSslCertificate> getSystemRootCAs();
|
||||
const QList<QSslCertificate> systemRootCAs();
|
||||
%Docstring
|
||||
Get root system certificate authorities
|
||||
systemRootCAs get root system certificate authorities
|
||||
:return: list of certificate authorities
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of QSslCertificate
|
||||
%End
|
||||
|
||||
const QList<QSslCertificate> getExtraFileCAs();
|
||||
const QList<QSslCertificate> extraFileCAs();
|
||||
%Docstring
|
||||
Get extra file-based certificate authorities
|
||||
extraFileCAs extra file-based certificate authorities
|
||||
:return: list of certificate authorities
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of QSslCertificate
|
||||
%End
|
||||
|
||||
const QList<QSslCertificate> getDatabaseCAs();
|
||||
const QList<QSslCertificate> databaseCAs();
|
||||
%Docstring
|
||||
Get database-stored certificate authorities
|
||||
databaseCAs get database-stored certificate authorities
|
||||
:return: list of certificate authorities
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of QSslCertificate
|
||||
%End
|
||||
|
||||
const QMap<QString, QSslCertificate> getMappedDatabaseCAs();
|
||||
const QMap<QString, QSslCertificate> mappedDatabaseCAs();
|
||||
%Docstring
|
||||
Get sha1-mapped database-stored certificate authorities
|
||||
mappedDatabaseCAs get sha1-mapped database-stored certificate authorities
|
||||
:return: sha1-mapped certificate authorities
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QMap<str, QSslCertificate>
|
||||
%End
|
||||
|
||||
@ -571,10 +608,12 @@ Store user trust value for a certificate
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QgsAuthCertUtils::CertTrustPolicy getCertTrustPolicy( const QSslCertificate &cert );
|
||||
QgsAuthCertUtils::CertTrustPolicy certTrustPolicy( const QSslCertificate &cert );
|
||||
%Docstring
|
||||
Get a whether certificate is trusted by user
|
||||
:return: DefaultTrust if certificate sha not in trust table, i.e. follows default trust policy
|
||||
certTrustPolicy get whether certificate ``cert`` is trusted by user
|
||||
\param cert
|
||||
:return: DefaultTrust if certificate sha not in trust table, i.e. follows default trust policy
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsAuthCertUtils.CertTrustPolicy
|
||||
%End
|
||||
|
||||
@ -590,9 +629,12 @@ Remove a certificate authority
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
QgsAuthCertUtils::CertTrustPolicy getCertificateTrustPolicy( const QSslCertificate &cert );
|
||||
QgsAuthCertUtils::CertTrustPolicy certificateTrustPolicy( const QSslCertificate &cert );
|
||||
%Docstring
|
||||
Get trust policy for a particular certificate
|
||||
certificateTrustPolicy get trust policy for a particular certificate ``cert``
|
||||
\param cert
|
||||
:return: DefaultTrust if certificate sha not in trust table, i.e. follows default trust policy
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsAuthCertUtils.CertTrustPolicy
|
||||
%End
|
||||
|
||||
@ -608,9 +650,11 @@ Get the default certificate trust policy perferred by user
|
||||
:rtype: QgsAuthCertUtils.CertTrustPolicy
|
||||
%End
|
||||
|
||||
const QMap<QgsAuthCertUtils::CertTrustPolicy, QStringList > getCertTrustCache();
|
||||
const QMap<QgsAuthCertUtils::CertTrustPolicy, QStringList > certTrustCache();
|
||||
%Docstring
|
||||
Get cache of certificate sha1s, per trust policy
|
||||
certTrustCache get cache of certificate sha1s, per trust policy
|
||||
:return: trust-policy-mapped certificate sha1s
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QMap<QgsAuthCertUtils.CertTrustPolicy, list of str >
|
||||
%End
|
||||
|
||||
@ -620,15 +664,20 @@ Rebuild certificate authority cache
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
const QList<QSslCertificate> getTrustedCaCerts( bool includeinvalid = false );
|
||||
const QList<QSslCertificate> trustedCaCerts( bool includeinvalid = false );
|
||||
%Docstring
|
||||
Get list of all trusted CA certificates
|
||||
trustedCaCerts get list of all trusted CA certificates
|
||||
\param includeinvalid whether invalid certs needs to be returned
|
||||
:return: list of certificates
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of QSslCertificate
|
||||
%End
|
||||
|
||||
const QList<QSslCertificate> getUntrustedCaCerts( QList<QSslCertificate> trustedCAs = QList<QSslCertificate>() );
|
||||
const QList<QSslCertificate> untrustedCaCerts( QList<QSslCertificate> trustedCAs = QList<QSslCertificate>() );
|
||||
%Docstring
|
||||
Get list of all untrusted CA certificates
|
||||
untrustedCaCerts get list of untrusted certificate authorities
|
||||
:return: list of certificates
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of QSslCertificate
|
||||
%End
|
||||
|
||||
@ -638,15 +687,19 @@ Rebuild trusted certificate authorities cache
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
const QList<QSslCertificate> getTrustedCaCertsCache();
|
||||
const QList<QSslCertificate> trustedCaCertsCache();
|
||||
%Docstring
|
||||
Get cache of trusted certificate authorities, ready for network connections
|
||||
trustedCaCertsCache cache of trusted certificate authorities, ready for network connections
|
||||
:return: list of certificates
|
||||
.. versionadded:: 3.0
|
||||
:rtype: list of QSslCertificate
|
||||
%End
|
||||
|
||||
const QByteArray getTrustedCaCertsPemText();
|
||||
const QByteArray trustedCaCertsPemText();
|
||||
%Docstring
|
||||
Get concatenated string of all trusted CA certificates
|
||||
trustedCaCertsPemText get concatenated string of all trusted CA certificates
|
||||
:return: bye array with all PEM encoded trusted CAs
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QByteArray
|
||||
%End
|
||||
|
||||
@ -701,9 +754,9 @@ The display name of the Authentication Manager
|
||||
%Docstring
|
||||
Custom logging signal to inform the user about master password <-> password manager interactions
|
||||
@see QgsMessageLog
|
||||
@param message Message to send
|
||||
@param tag Associated tag (title)
|
||||
@param level Message log level
|
||||
\param message Message to send
|
||||
\param tag Associated tag (title)
|
||||
\param level Message log level
|
||||
%End
|
||||
|
||||
|
||||
|
@ -12659,7 +12659,7 @@ void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors
|
||||
QString digest( QgsAuthCertUtils::shaHexForCert( reply->sslConfiguration().peerCertificate() ) );
|
||||
QString dgsthostport( QStringLiteral( "%1:%2" ).arg( digest, hostport ) );
|
||||
|
||||
const QHash<QString, QSet<QSslError::SslError> > &errscache( QgsApplication::authManager()->getIgnoredSslErrorCache() );
|
||||
const QHash<QString, QSet<QSslError::SslError> > &errscache( QgsApplication::authManager()->ignoredSslErrorCache() );
|
||||
|
||||
if ( errscache.contains( dgsthostport ) )
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ void QgsAuthIdentCertEdit::populateIdentityComboBox()
|
||||
{
|
||||
cmbIdentityCert->addItem( tr( "Select identity..." ), "" );
|
||||
|
||||
QList<QSslCertificate> certs( QgsApplication::authManager()->getCertIdentities() );
|
||||
QList<QSslCertificate> certs( QgsApplication::authManager()->certIdentities() );
|
||||
if ( !certs.isEmpty() )
|
||||
{
|
||||
cmbIdentityCert->setIconSize( QSize( 26, 22 ) );
|
||||
|
@ -144,7 +144,7 @@ bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionIt
|
||||
// save CAs to temp file
|
||||
QString caFilePath = QgsAuthCertUtils::pemTextToTempFile(
|
||||
pkiTempFileBase.arg( QUuid::createUuid().toString() ),
|
||||
QgsApplication::authManager()->getTrustedCaCertsPemText() );
|
||||
QgsApplication::authManager()->trustedCaCertsPemText() );
|
||||
if ( caFilePath.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
@ -246,7 +246,7 @@ QgsPkiConfigBundle *QgsAuthIdentCertMethod::getPkiConfigBundle( const QString &a
|
||||
}
|
||||
|
||||
// get identity from database
|
||||
QPair<QSslCertificate, QSslKey> cibundle( QgsApplication::authManager()->getCertIdentityBundle( mconfig.config( QStringLiteral( "certid" ) ) ) );
|
||||
QPair<QSslCertificate, QSslKey> cibundle( QgsApplication::authManager()->certIdentityBundle( mconfig.config( QStringLiteral( "certid" ) ) ) );
|
||||
|
||||
// init client cert
|
||||
// Note: if this is not valid, no sense continuing
|
||||
|
@ -161,17 +161,17 @@ bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionIte
|
||||
{
|
||||
if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) )
|
||||
{
|
||||
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->getTrustedCaCerts(), pkibundle->caChain() );
|
||||
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), pkibundle->caChain() );
|
||||
}
|
||||
else
|
||||
{
|
||||
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->getTrustedCaCerts(),
|
||||
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(),
|
||||
QgsAuthCertUtils::casRemoveSelfSigned( pkibundle->caChain() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cas = QgsApplication::authManager()->getTrustedCaCerts();
|
||||
cas = QgsApplication::authManager()->trustedCaCerts();
|
||||
}
|
||||
|
||||
// save CAs to temp file
|
||||
|
@ -161,17 +161,17 @@ bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems
|
||||
{
|
||||
if ( pkibundle->config().config( QStringLiteral( "addrootca" ), QStringLiteral( "false" ) ) == QStringLiteral( "true" ) )
|
||||
{
|
||||
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->getTrustedCaCerts(), pkibundle->caChain() );
|
||||
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(), pkibundle->caChain() );
|
||||
}
|
||||
else
|
||||
{
|
||||
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->getTrustedCaCerts(),
|
||||
cas = QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCerts(),
|
||||
QgsAuthCertUtils::casRemoveSelfSigned( pkibundle->caChain() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cas = QgsApplication::authManager()->getTrustedCaCerts();
|
||||
cas = QgsApplication::authManager()->trustedCaCerts();
|
||||
}
|
||||
|
||||
// save CAs to temp file
|
||||
|
@ -947,9 +947,9 @@ QList<QgsAuthCertUtils::CertUsageType> QgsAuthCertUtils::certificateUsageTypes(
|
||||
|
||||
// ask QCA what it thinks about potential usages
|
||||
QCA::CertificateCollection trustedCAs(
|
||||
qtCertsToQcaCollection( QgsApplication::authManager()->getTrustedCaCertsCache() ) );
|
||||
qtCertsToQcaCollection( QgsApplication::authManager()->trustedCaCertsCache() ) );
|
||||
QCA::CertificateCollection untrustedCAs(
|
||||
qtCertsToQcaCollection( QgsApplication::authManager()->getUntrustedCaCerts() ) );
|
||||
qtCertsToQcaCollection( QgsApplication::authManager()->untrustedCaCerts() ) );
|
||||
|
||||
QCA::Validity v_any;
|
||||
v_any = qcacert.validate( trustedCAs, untrustedCAs, QCA::UsageAny, QCA::ValidateAll );
|
||||
@ -1251,7 +1251,7 @@ QList<QSslError> QgsAuthCertUtils::validateCertChain( const QList<QSslCertificat
|
||||
for ( const auto &cert : certificateChain )
|
||||
{
|
||||
bool untrusted = false;
|
||||
for ( const auto &untrustedCert : QgsApplication::authManager()->getUntrustedCaCerts() )
|
||||
for ( const auto &untrustedCert : QgsApplication::authManager()->untrustedCaCerts() )
|
||||
{
|
||||
if ( cert.digest( ) == untrustedCert.digest( ) )
|
||||
{
|
||||
|
@ -1535,7 +1535,7 @@ bool QgsAuthManager::storeAuthSetting( const QString &key, const QVariant &value
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant QgsAuthManager::getAuthSetting( const QString &key, const QVariant &defaultValue, bool decrypt )
|
||||
QVariant QgsAuthManager::authSetting( const QString &key, const QVariant &defaultValue, bool decrypt )
|
||||
{
|
||||
if ( key.isEmpty() )
|
||||
return QVariant();
|
||||
@ -1694,7 +1694,7 @@ bool QgsAuthManager::storeCertIdentity( const QSslCertificate &cert, const QSslK
|
||||
return true;
|
||||
}
|
||||
|
||||
const QSslCertificate QgsAuthManager::getCertIdentity( const QString &id )
|
||||
const QSslCertificate QgsAuthManager::certIdentity( const QString &id )
|
||||
{
|
||||
QSslCertificate emptycert;
|
||||
QSslCertificate cert;
|
||||
@ -1727,7 +1727,7 @@ const QSslCertificate QgsAuthManager::getCertIdentity( const QString &id )
|
||||
return cert;
|
||||
}
|
||||
|
||||
const QPair<QSslCertificate, QSslKey> QgsAuthManager::getCertIdentityBundle( const QString &id )
|
||||
const QPair<QSslCertificate, QSslKey> QgsAuthManager::certIdentityBundle( const QString &id )
|
||||
{
|
||||
QPair<QSslCertificate, QSslKey> bundle;
|
||||
if ( id.isEmpty() )
|
||||
@ -1781,9 +1781,9 @@ const QPair<QSslCertificate, QSslKey> QgsAuthManager::getCertIdentityBundle( con
|
||||
return bundle;
|
||||
}
|
||||
|
||||
const QStringList QgsAuthManager::getCertIdentityBundleToPem( const QString &id )
|
||||
const QStringList QgsAuthManager::certIdentityBundleToPem( const QString &id )
|
||||
{
|
||||
QPair<QSslCertificate, QSslKey> bundle( getCertIdentityBundle( id ) );
|
||||
QPair<QSslCertificate, QSslKey> bundle( certIdentityBundle( id ) );
|
||||
if ( bundle.first.isValid() && !bundle.second.isNull() )
|
||||
{
|
||||
return QStringList() << QString( bundle.first.toPem() ) << QString( bundle.second.toPem() );
|
||||
@ -1791,7 +1791,7 @@ const QStringList QgsAuthManager::getCertIdentityBundleToPem( const QString &id
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
const QList<QSslCertificate> QgsAuthManager::getCertIdentities()
|
||||
const QList<QSslCertificate> QgsAuthManager::certIdentities()
|
||||
{
|
||||
QList<QSslCertificate> certs;
|
||||
|
||||
@ -1812,7 +1812,7 @@ const QList<QSslCertificate> QgsAuthManager::getCertIdentities()
|
||||
return certs;
|
||||
}
|
||||
|
||||
QStringList QgsAuthManager::getCertIdentityIds() const
|
||||
QStringList QgsAuthManager::certIdentityIds() const
|
||||
{
|
||||
QStringList identityids = QStringList();
|
||||
|
||||
@ -1937,7 +1937,7 @@ bool QgsAuthManager::storeSslCertCustomConfig( const QgsAuthConfigSslServer &con
|
||||
return true;
|
||||
}
|
||||
|
||||
const QgsAuthConfigSslServer QgsAuthManager::getSslCertCustomConfig( const QString &id, const QString &hostport )
|
||||
const QgsAuthConfigSslServer QgsAuthManager::sslCertCustomConfig( const QString &id, const QString &hostport )
|
||||
{
|
||||
QgsAuthConfigSslServer config;
|
||||
|
||||
@ -1978,7 +1978,7 @@ const QgsAuthConfigSslServer QgsAuthManager::getSslCertCustomConfig( const QStri
|
||||
return config;
|
||||
}
|
||||
|
||||
const QgsAuthConfigSslServer QgsAuthManager::getSslCertCustomConfigByHost( const QString &hostport )
|
||||
const QgsAuthConfigSslServer QgsAuthManager::sslCertCustomConfigByHost( const QString &hostport )
|
||||
{
|
||||
QgsAuthConfigSslServer config;
|
||||
|
||||
@ -2018,7 +2018,7 @@ const QgsAuthConfigSslServer QgsAuthManager::getSslCertCustomConfigByHost( const
|
||||
return config;
|
||||
}
|
||||
|
||||
const QList<QgsAuthConfigSslServer> QgsAuthManager::getSslCertCustomConfigs()
|
||||
const QList<QgsAuthConfigSslServer> QgsAuthManager::sslCertCustomConfigs()
|
||||
{
|
||||
QList<QgsAuthConfigSslServer> configs;
|
||||
|
||||
@ -2322,7 +2322,7 @@ bool QgsAuthManager::storeCertAuthority( const QSslCertificate &cert )
|
||||
return true;
|
||||
}
|
||||
|
||||
const QSslCertificate QgsAuthManager::getCertAuthority( const QString &id )
|
||||
const QSslCertificate QgsAuthManager::certAuthority( const QString &id )
|
||||
{
|
||||
QSslCertificate emptycert;
|
||||
QSslCertificate cert;
|
||||
@ -2421,7 +2421,7 @@ bool QgsAuthManager::removeCertAuthority( const QSslCertificate &cert )
|
||||
return true;
|
||||
}
|
||||
|
||||
const QList<QSslCertificate> QgsAuthManager::getSystemRootCAs()
|
||||
const QList<QSslCertificate> QgsAuthManager::systemRootCAs()
|
||||
{
|
||||
#ifndef Q_OS_MAC
|
||||
return QSslSocket::systemCaCertificates();
|
||||
@ -2431,15 +2431,15 @@ const QList<QSslCertificate> QgsAuthManager::getSystemRootCAs()
|
||||
#endif
|
||||
}
|
||||
|
||||
const QList<QSslCertificate> QgsAuthManager::getExtraFileCAs()
|
||||
const QList<QSslCertificate> QgsAuthManager::extraFileCAs()
|
||||
{
|
||||
QList<QSslCertificate> certs;
|
||||
QList<QSslCertificate> filecerts;
|
||||
QVariant cafileval = QgsAuthManager::instance()->getAuthSetting( QStringLiteral( "cafile" ) );
|
||||
QVariant cafileval = QgsAuthManager::instance()->authSetting( QStringLiteral( "cafile" ) );
|
||||
if ( cafileval.isNull() )
|
||||
return certs;
|
||||
|
||||
QVariant allowinvalid = QgsAuthManager::instance()->getAuthSetting( QStringLiteral( "cafileallowinvalid" ), QVariant( false ) );
|
||||
QVariant allowinvalid = QgsAuthManager::instance()->authSetting( QStringLiteral( "cafileallowinvalid" ), QVariant( false ) );
|
||||
if ( allowinvalid.isNull() )
|
||||
return certs;
|
||||
|
||||
@ -2464,7 +2464,7 @@ const QList<QSslCertificate> QgsAuthManager::getExtraFileCAs()
|
||||
return certs;
|
||||
}
|
||||
|
||||
const QList<QSslCertificate> QgsAuthManager::getDatabaseCAs()
|
||||
const QList<QSslCertificate> QgsAuthManager::databaseCAs()
|
||||
{
|
||||
QList<QSslCertificate> certs;
|
||||
|
||||
@ -2485,18 +2485,18 @@ const QList<QSslCertificate> QgsAuthManager::getDatabaseCAs()
|
||||
return certs;
|
||||
}
|
||||
|
||||
const QMap<QString, QSslCertificate> QgsAuthManager::getMappedDatabaseCAs()
|
||||
const QMap<QString, QSslCertificate> QgsAuthManager::mappedDatabaseCAs()
|
||||
{
|
||||
return QgsAuthCertUtils::mapDigestToCerts( getDatabaseCAs() );
|
||||
return QgsAuthCertUtils::mapDigestToCerts( databaseCAs() );
|
||||
}
|
||||
|
||||
bool QgsAuthManager::rebuildCaCertsCache()
|
||||
{
|
||||
mCaCertsCache.clear();
|
||||
// in reverse order of precedence, with regards to duplicates, so QMap inserts overwrite
|
||||
insertCaCertInCache( QgsAuthCertUtils::SystemRoot, getSystemRootCAs() );
|
||||
insertCaCertInCache( QgsAuthCertUtils::FromFile, getExtraFileCAs() );
|
||||
insertCaCertInCache( QgsAuthCertUtils::InDatabase, getDatabaseCAs() );
|
||||
insertCaCertInCache( QgsAuthCertUtils::SystemRoot, systemRootCAs() );
|
||||
insertCaCertInCache( QgsAuthCertUtils::FromFile, extraFileCAs() );
|
||||
insertCaCertInCache( QgsAuthCertUtils::InDatabase, databaseCAs() );
|
||||
|
||||
bool res = !mCaCertsCache.isEmpty(); // should at least contain system root CAs
|
||||
QgsDebugMsg( QString( "Rebuild of CA certs cache %1" ).arg( res ? "SUCCEEDED" : "FAILED" ) );
|
||||
@ -2541,7 +2541,7 @@ bool QgsAuthManager::storeCertTrustPolicy( const QSslCertificate &cert, QgsAuthC
|
||||
return true;
|
||||
}
|
||||
|
||||
QgsAuthCertUtils::CertTrustPolicy QgsAuthManager::getCertTrustPolicy( const QSslCertificate &cert )
|
||||
QgsAuthCertUtils::CertTrustPolicy QgsAuthManager::certTrustPolicy( const QSslCertificate &cert )
|
||||
{
|
||||
if ( cert.isNull() )
|
||||
{
|
||||
@ -2624,7 +2624,7 @@ bool QgsAuthManager::removeCertTrustPolicy( const QSslCertificate &cert )
|
||||
return true;
|
||||
}
|
||||
|
||||
QgsAuthCertUtils::CertTrustPolicy QgsAuthManager::getCertificateTrustPolicy( const QSslCertificate &cert )
|
||||
QgsAuthCertUtils::CertTrustPolicy QgsAuthManager::certificateTrustPolicy( const QSslCertificate &cert )
|
||||
{
|
||||
if ( cert.isNull() )
|
||||
{
|
||||
@ -2659,7 +2659,7 @@ bool QgsAuthManager::setDefaultCertTrustPolicy( QgsAuthCertUtils::CertTrustPolic
|
||||
|
||||
QgsAuthCertUtils::CertTrustPolicy QgsAuthManager::defaultCertTrustPolicy()
|
||||
{
|
||||
QVariant policy( getAuthSetting( QStringLiteral( "certdefaulttrust" ) ) );
|
||||
QVariant policy( authSetting( QStringLiteral( "certdefaulttrust" ) ) );
|
||||
if ( policy.isNull() )
|
||||
{
|
||||
return QgsAuthCertUtils::Trusted;
|
||||
@ -2700,7 +2700,7 @@ bool QgsAuthManager::rebuildCertTrustCache()
|
||||
return true;
|
||||
}
|
||||
|
||||
const QList<QSslCertificate> QgsAuthManager::getTrustedCaCerts( bool includeinvalid )
|
||||
const QList<QSslCertificate> QgsAuthManager::trustedCaCerts( bool includeinvalid )
|
||||
{
|
||||
QgsAuthCertUtils::CertTrustPolicy defaultpolicy( defaultCertTrustPolicy() );
|
||||
QStringList trustedids = mCertTrustCache.value( QgsAuthCertUtils::Trusted );
|
||||
@ -2733,7 +2733,7 @@ const QList<QSslCertificate> QgsAuthManager::getTrustedCaCerts( bool includeinva
|
||||
return trustedcerts;
|
||||
}
|
||||
|
||||
const QList<QSslCertificate> QgsAuthManager::getUntrustedCaCerts( QList<QSslCertificate> trustedCAs )
|
||||
const QList<QSslCertificate> QgsAuthManager::untrustedCaCerts( QList<QSslCertificate> trustedCAs )
|
||||
{
|
||||
if ( trustedCAs.isEmpty() )
|
||||
{
|
||||
@ -2741,7 +2741,7 @@ const QList<QSslCertificate> QgsAuthManager::getUntrustedCaCerts( QList<QSslCert
|
||||
{
|
||||
rebuildTrustedCaCertsCache();
|
||||
}
|
||||
trustedCAs = getTrustedCaCertsCache();
|
||||
trustedCAs = trustedCaCertsCache();
|
||||
}
|
||||
|
||||
const QList<QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate> > &certpairs( mCaCertsCache.values() );
|
||||
@ -2760,15 +2760,15 @@ const QList<QSslCertificate> QgsAuthManager::getUntrustedCaCerts( QList<QSslCert
|
||||
|
||||
bool QgsAuthManager::rebuildTrustedCaCertsCache()
|
||||
{
|
||||
mTrustedCaCertsCache = getTrustedCaCerts();
|
||||
mTrustedCaCertsCache = trustedCaCerts();
|
||||
QgsDebugMsg( "Rebuilt trusted cert authorities cache" );
|
||||
// TODO: add some error trapping for the operation
|
||||
return true;
|
||||
}
|
||||
|
||||
const QByteArray QgsAuthManager::getTrustedCaCertsPemText()
|
||||
const QByteArray QgsAuthManager::trustedCaCertsPemText()
|
||||
{
|
||||
return QgsAuthCertUtils::certsToPemText( getTrustedCaCertsCache() );
|
||||
return QgsAuthCertUtils::certsToPemText( trustedCaCertsCache() );
|
||||
}
|
||||
|
||||
bool QgsAuthManager::passwordHelperSync()
|
||||
@ -3471,7 +3471,7 @@ bool QgsAuthManager::reencryptAllAuthenticationIdentities( const QString &prevpa
|
||||
return false;
|
||||
|
||||
bool res = true;
|
||||
const QStringList ids = getCertIdentityIds();
|
||||
const QStringList ids = certIdentityIds();
|
||||
for ( const auto &identid : ids )
|
||||
{
|
||||
res = res && reencryptAuthenticationIdentity( identid, prevpass, prevciv );
|
||||
|
@ -361,8 +361,15 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
//! Store an authentication setting (stored as string via QVariant( value ).toString() )
|
||||
bool storeAuthSetting( const QString &key, const QVariant &value, bool encrypt = false );
|
||||
|
||||
//! Get an authentication setting (retrieved as string and returned as QVariant( QString ))
|
||||
QVariant getAuthSetting( const QString &key, const QVariant &defaultValue = QVariant(), bool decrypt = false );
|
||||
/**
|
||||
* \brief authSetting get an authentication setting (retrieved as string and returned as QVariant( QString ))
|
||||
* \param key setting key
|
||||
* \param defaultValue
|
||||
* \param decrypt if the value needs decrypted
|
||||
* \return QVariant( QString ) authentication setting
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QVariant authSetting( const QString &key, const QVariant &defaultValue = QVariant(), bool decrypt = false );
|
||||
|
||||
//! Check if an authentication setting exists
|
||||
bool existsAuthSetting( const QString &key );
|
||||
@ -379,23 +386,46 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
//! Store a certificate identity
|
||||
bool storeCertIdentity( const QSslCertificate &cert, const QSslKey &key );
|
||||
|
||||
//! Get a certificate identity by id (sha hash)
|
||||
const QSslCertificate getCertIdentity( const QString &id );
|
||||
/**
|
||||
* \brief certIdentity get a certificate identity by \a id (sha hash)
|
||||
* \param id sha hash of the cert
|
||||
* \return the certificate
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QSslCertificate certIdentity( const QString &id );
|
||||
|
||||
/**
|
||||
* Get a certificate identity bundle by id (sha hash).
|
||||
* Get a certificate identity bundle by \a id (sha hash).
|
||||
* \param id sha shash
|
||||
* \return a pair with the certificate and its SSL key
|
||||
* \note not available in Python bindings
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QPair<QSslCertificate, QSslKey> getCertIdentityBundle( const QString &id ) SIP_SKIP;
|
||||
const QPair<QSslCertificate, QSslKey> certIdentityBundle( const QString &id ) SIP_SKIP;
|
||||
|
||||
//! Get a certificate identity bundle by id (sha hash) returned as PEM text
|
||||
const QStringList getCertIdentityBundleToPem( const QString &id );
|
||||
/**
|
||||
* \brief certIdentityBundleToPem get a certificate identity bundle by \a id (sha hash) returned as PEM text
|
||||
* \param id sha hash
|
||||
* \return a list of strings
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QStringList certIdentityBundleToPem( const QString &id );
|
||||
|
||||
//! Get certificate identities
|
||||
const QList<QSslCertificate> getCertIdentities();
|
||||
/**
|
||||
* \brief certIdentities get certificate identities
|
||||
* \return list of certificates
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QList<QSslCertificate> certIdentities();
|
||||
|
||||
//! Get list of certificate identity ids from database
|
||||
QStringList getCertIdentityIds() const;
|
||||
//!
|
||||
|
||||
/**
|
||||
* \brief certIdentityIds get list of certificate identity ids from database
|
||||
* \return list of certificate ids
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QStringList certIdentityIds() const;
|
||||
|
||||
//! Check if a certificate identity exists
|
||||
bool existsCertIdentity( const QString &id );
|
||||
@ -407,14 +437,29 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
//! Store an SSL certificate custom config
|
||||
bool storeSslCertCustomConfig( const QgsAuthConfigSslServer &config );
|
||||
|
||||
//! Get an SSL certificate custom config by id (sha hash) and host:port
|
||||
const QgsAuthConfigSslServer getSslCertCustomConfig( const QString &id, const QString &hostport );
|
||||
/**
|
||||
* \brief sslCertCustomConfig get an SSL certificate custom config by \a id (sha hash) and \a hostport (host:port)
|
||||
* \param id sha hash
|
||||
* \param hostport string host:port
|
||||
* \return a SSL certificate custom config
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QgsAuthConfigSslServer sslCertCustomConfig( const QString &id, const QString &hostport );
|
||||
|
||||
//! Get an SSL certificate custom config by host:port
|
||||
const QgsAuthConfigSslServer getSslCertCustomConfigByHost( const QString &hostport );
|
||||
/**
|
||||
* \brief sslCertCustomConfigByHost get an SSL certificate custom config by \a hostport (host:port)
|
||||
* \param hostport host:port
|
||||
* \return a SSL certificate custom config
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QgsAuthConfigSslServer sslCertCustomConfigByHost( const QString &hostport );
|
||||
|
||||
//! Get SSL certificate custom configs
|
||||
const QList<QgsAuthConfigSslServer> getSslCertCustomConfigs();
|
||||
/**
|
||||
* \brief sslCertCustomConfigs get SSL certificate custom configs
|
||||
* \return list of SSL certificate custom config
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QList<QgsAuthConfigSslServer> sslCertCustomConfigs();
|
||||
|
||||
//! Check if SSL certificate custom config exists
|
||||
bool existsSslCertCustomConfig( const QString &id, const QString &hostport );
|
||||
@ -423,10 +468,12 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
bool removeSslCertCustomConfig( const QString &id, const QString &hostport );
|
||||
|
||||
/**
|
||||
* Get ignored SSL error cache, keyed with cert/connection's sha:host:port.
|
||||
* \brief ignoredSslErrorCache Get ignored SSL error cache, keyed with cert/connection's sha:host:port.
|
||||
* \note not available in Python bindings
|
||||
* \return hash keyed with cert/connection's sha:host:port.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QHash<QString, QSet<QSslError::SslError> > getIgnoredSslErrorCache() { return mIgnoredSslErrorsCache; } SIP_SKIP
|
||||
QHash<QString, QSet<QSslError::SslError> > ignoredSslErrorCache() { return mIgnoredSslErrorsCache; } SIP_SKIP
|
||||
|
||||
//! Utility function to dump the cache for debug purposes
|
||||
void dumpIgnoredSslErrorsCache_();
|
||||
@ -448,7 +495,14 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
bool storeCertAuthority( const QSslCertificate &cert );
|
||||
|
||||
//! Get a certificate authority by id (sha hash)
|
||||
const QSslCertificate getCertAuthority( const QString &id );
|
||||
|
||||
/**
|
||||
* \brief certAuthority get a certificate authority by \a id (sha hash)
|
||||
* \param id sha hash
|
||||
* \return a certificate
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QSslCertificate certAuthority( const QString &id );
|
||||
|
||||
//! Check if a certificate authority exists
|
||||
bool existsCertAuthority( const QSslCertificate &cert );
|
||||
@ -456,23 +510,41 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
//! Remove a certificate authority
|
||||
bool removeCertAuthority( const QSslCertificate &cert );
|
||||
|
||||
//! Get root system certificate authorities
|
||||
const QList<QSslCertificate> getSystemRootCAs();
|
||||
|
||||
//! Get extra file-based certificate authorities
|
||||
const QList<QSslCertificate> getExtraFileCAs();
|
||||
|
||||
//! Get database-stored certificate authorities
|
||||
const QList<QSslCertificate> getDatabaseCAs();
|
||||
|
||||
//! Get sha1-mapped database-stored certificate authorities
|
||||
const QMap<QString, QSslCertificate> getMappedDatabaseCAs();
|
||||
/**
|
||||
* \brief systemRootCAs get root system certificate authorities
|
||||
* \return list of certificate authorities
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QList<QSslCertificate> systemRootCAs();
|
||||
|
||||
/**
|
||||
* Get all CA certs mapped to their sha1 from cache.
|
||||
* \note not available in Python bindings
|
||||
* \brief extraFileCAs extra file-based certificate authorities
|
||||
* \return list of certificate authorities
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QMap<QString, QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate> > getCaCertsCache() SIP_SKIP
|
||||
const QList<QSslCertificate> extraFileCAs();
|
||||
|
||||
/**
|
||||
* \brief databaseCAs get database-stored certificate authorities
|
||||
* \return list of certificate authorities
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QList<QSslCertificate> databaseCAs();
|
||||
|
||||
/**
|
||||
* \brief mappedDatabaseCAs get sha1-mapped database-stored certificate authorities
|
||||
* \return sha1-mapped certificate authorities
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QMap<QString, QSslCertificate> mappedDatabaseCAs();
|
||||
|
||||
/**
|
||||
* \brief caCertsCache get all CA certs mapped to their sha1 from cache.
|
||||
* \return map of sha1 <source, certificates>
|
||||
* \note not available in Python bindings
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QMap<QString, QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate> > caCertsCache() SIP_SKIP
|
||||
{
|
||||
return mCaCertsCache;
|
||||
}
|
||||
@ -484,10 +556,12 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
bool storeCertTrustPolicy( const QSslCertificate &cert, QgsAuthCertUtils::CertTrustPolicy policy );
|
||||
|
||||
/**
|
||||
* Get a whether certificate is trusted by user
|
||||
\returns DefaultTrust if certificate sha not in trust table, i.e. follows default trust policy
|
||||
* \brief certTrustPolicy get whether certificate \a cert is trusted by user
|
||||
* \param cert
|
||||
* \return DefaultTrust if certificate sha not in trust table, i.e. follows default trust policy
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QgsAuthCertUtils::CertTrustPolicy getCertTrustPolicy( const QSslCertificate &cert );
|
||||
QgsAuthCertUtils::CertTrustPolicy certTrustPolicy( const QSslCertificate &cert );
|
||||
|
||||
//! Remove a group certificate authorities
|
||||
bool removeCertTrustPolicies( const QList<QSslCertificate> &certs );
|
||||
@ -495,8 +569,13 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
//! Remove a certificate authority
|
||||
bool removeCertTrustPolicy( const QSslCertificate &cert );
|
||||
|
||||
//! Get trust policy for a particular certificate
|
||||
QgsAuthCertUtils::CertTrustPolicy getCertificateTrustPolicy( const QSslCertificate &cert );
|
||||
/**
|
||||
* \brief certificateTrustPolicy get trust policy for a particular certificate \a cert
|
||||
* \param cert
|
||||
* \return DefaultTrust if certificate sha not in trust table, i.e. follows default trust policy
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QgsAuthCertUtils::CertTrustPolicy certificateTrustPolicy( const QSslCertificate &cert );
|
||||
|
||||
//! Set the default certificate trust policy perferred by user
|
||||
bool setDefaultCertTrustPolicy( QgsAuthCertUtils::CertTrustPolicy policy );
|
||||
@ -504,26 +583,47 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
//! Get the default certificate trust policy perferred by user
|
||||
QgsAuthCertUtils::CertTrustPolicy defaultCertTrustPolicy();
|
||||
|
||||
//! Get cache of certificate sha1s, per trust policy
|
||||
const QMap<QgsAuthCertUtils::CertTrustPolicy, QStringList > getCertTrustCache() { return mCertTrustCache; }
|
||||
/**
|
||||
* \brief certTrustCache get cache of certificate sha1s, per trust policy
|
||||
* \return trust-policy-mapped certificate sha1s
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QMap<QgsAuthCertUtils::CertTrustPolicy, QStringList > certTrustCache() { return mCertTrustCache; }
|
||||
|
||||
//! Rebuild certificate authority cache
|
||||
bool rebuildCertTrustCache();
|
||||
|
||||
//! Get list of all trusted CA certificates
|
||||
const QList<QSslCertificate> getTrustedCaCerts( bool includeinvalid = false );
|
||||
/**
|
||||
* \brief trustedCaCerts get list of all trusted CA certificates
|
||||
* \param includeinvalid whether invalid certs needs to be returned
|
||||
* \return list of certificates
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QList<QSslCertificate> trustedCaCerts( bool includeinvalid = false );
|
||||
|
||||
//! Get list of all untrusted CA certificates
|
||||
const QList<QSslCertificate> getUntrustedCaCerts( QList<QSslCertificate> trustedCAs = QList<QSslCertificate>() );
|
||||
/**
|
||||
* \brief untrustedCaCerts get list of untrusted certificate authorities
|
||||
* \return list of certificates
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QList<QSslCertificate> untrustedCaCerts( QList<QSslCertificate> trustedCAs = QList<QSslCertificate>() );
|
||||
|
||||
//! Rebuild trusted certificate authorities cache
|
||||
bool rebuildTrustedCaCertsCache();
|
||||
|
||||
//! Get cache of trusted certificate authorities, ready for network connections
|
||||
const QList<QSslCertificate> getTrustedCaCertsCache() { return mTrustedCaCertsCache; }
|
||||
/**
|
||||
* \brief trustedCaCertsCache cache of trusted certificate authorities, ready for network connections
|
||||
* \return list of certificates
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QList<QSslCertificate> trustedCaCertsCache() { return mTrustedCaCertsCache; }
|
||||
|
||||
//! Get concatenated string of all trusted CA certificates
|
||||
const QByteArray getTrustedCaCertsPemText();
|
||||
/**
|
||||
* \brief trustedCaCertsPemText get concatenated string of all trusted CA certificates
|
||||
* \return bye array with all PEM encoded trusted CAs
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
const QByteArray trustedCaCertsPemText();
|
||||
|
||||
#endif
|
||||
|
||||
@ -604,9 +704,9 @@ class CORE_EXPORT QgsAuthManager : public QObject
|
||||
/**
|
||||
* Custom logging signal to inform the user about master password <-> password manager interactions
|
||||
* @see QgsMessageLog
|
||||
* @param message Message to send
|
||||
* @param tag Associated tag (title)
|
||||
* @param level Message log level
|
||||
* \param message Message to send
|
||||
* \param tag Associated tag (title)
|
||||
* \param level Message log level
|
||||
*/
|
||||
void passwordHelperMessageOut( const QString &message, const QString &tag = QgsAuthManager::AUTH_MAN_TAG, QgsAuthManager::MessageLevel level = QgsAuthManager::INFO );
|
||||
|
||||
|
@ -185,12 +185,12 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
|
||||
QgsDebugMsg( "Adding trusted CA certs to request" );
|
||||
QSslConfiguration sslconfig( pReq->sslConfiguration() );
|
||||
// Merge trusted CAs with any additional CAs added by the authentication methods
|
||||
sslconfig.setCaCertificates( QgsAuthCertUtils::casMerge( QgsApplication::authManager()->getTrustedCaCertsCache(), sslconfig.caCertificates( ) ) );
|
||||
sslconfig.setCaCertificates( QgsAuthCertUtils::casMerge( QgsApplication::authManager()->trustedCaCertsCache(), sslconfig.caCertificates( ) ) );
|
||||
// check for SSL cert custom config
|
||||
QString hostport( QStringLiteral( "%1:%2" )
|
||||
.arg( pReq->url().host().trimmed() )
|
||||
.arg( pReq->url().port() != -1 ? pReq->url().port() : 443 ) );
|
||||
QgsAuthConfigSslServer servconfig = QgsApplication::authManager()->getSslCertCustomConfigByHost( hostport.trimmed() );
|
||||
QgsAuthConfigSslServer servconfig = QgsApplication::authManager()->sslCertCustomConfigByHost( hostport.trimmed() );
|
||||
if ( !servconfig.isNull() )
|
||||
{
|
||||
QgsDebugMsg( QString( "Adding SSL custom config to request for %1" ).arg( hostport ) );
|
||||
|
@ -76,14 +76,14 @@ QgsAuthAuthoritiesEditor::QgsAuthAuthoritiesEditor( QWidget *parent )
|
||||
|
||||
connect( btnViewRefresh, &QAbstractButton::clicked, this, &QgsAuthAuthoritiesEditor::refreshCaCertsView );
|
||||
|
||||
QVariant cafileval = QgsApplication::authManager()->getAuthSetting( QStringLiteral( "cafile" ) );
|
||||
QVariant cafileval = QgsApplication::authManager()->authSetting( QStringLiteral( "cafile" ) );
|
||||
if ( !cafileval.isNull() )
|
||||
{
|
||||
leCaFile->setText( cafileval.toString() );
|
||||
}
|
||||
|
||||
btnGroupByOrg->setChecked( false );
|
||||
QVariant sortbyval = QgsApplication::authManager()->getAuthSetting( QStringLiteral( "casortby" ), QVariant( false ) );
|
||||
QVariant sortbyval = QgsApplication::authManager()->authSetting( QStringLiteral( "casortby" ), QVariant( false ) );
|
||||
if ( !sortbyval.isNull() )
|
||||
btnGroupByOrg->setChecked( sortbyval.toBool() );
|
||||
|
||||
@ -172,7 +172,7 @@ void QgsAuthAuthoritiesEditor::populateDatabaseCaCerts()
|
||||
|
||||
bool expanded = mDbCaSecItem->isExpanded();
|
||||
populateCaCertsSection( mDbCaSecItem,
|
||||
QgsApplication::authManager()->getDatabaseCAs(),
|
||||
QgsApplication::authManager()->databaseCAs(),
|
||||
QgsAuthAuthoritiesEditor::DbCaCert );
|
||||
mDbCaSecItem->setExpanded( expanded );
|
||||
}
|
||||
@ -183,7 +183,7 @@ void QgsAuthAuthoritiesEditor::populateFileCaCerts()
|
||||
|
||||
bool expanded = mFileCaSecItem->isExpanded();
|
||||
populateCaCertsSection( mFileCaSecItem,
|
||||
QgsApplication::authManager()->getExtraFileCAs(),
|
||||
QgsApplication::authManager()->extraFileCAs(),
|
||||
QgsAuthAuthoritiesEditor::FileCaCert );
|
||||
mFileCaSecItem->setExpanded( expanded );
|
||||
}
|
||||
@ -194,7 +194,7 @@ void QgsAuthAuthoritiesEditor::populateRootCaCerts()
|
||||
|
||||
bool expanded = mRootCaSecItem->isExpanded();
|
||||
populateCaCertsSection( mRootCaSecItem,
|
||||
QgsApplication::authManager()->getSystemRootCAs(),
|
||||
QgsApplication::authManager()->systemRootCAs(),
|
||||
QgsAuthAuthoritiesEditor::RootCaCert );
|
||||
mRootCaSecItem->setExpanded( expanded );
|
||||
}
|
||||
@ -326,7 +326,7 @@ void QgsAuthAuthoritiesEditor::appendCertsToItem( const QList<QSslCertificate> &
|
||||
|
||||
void QgsAuthAuthoritiesEditor::updateCertTrustPolicyCache()
|
||||
{
|
||||
mCertTrustCache = QgsApplication::authManager()->getCertTrustCache();
|
||||
mCertTrustCache = QgsApplication::authManager()->certTrustCache();
|
||||
}
|
||||
|
||||
void QgsAuthAuthoritiesEditor::populateUtilitiesMenu()
|
||||
@ -353,7 +353,7 @@ void QgsAuthAuthoritiesEditor::showCertInfo( QTreeWidgetItem *item )
|
||||
QString digest( item->data( 0, Qt::UserRole ).toString() );
|
||||
|
||||
QMap<QString, QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate> > cacertscache(
|
||||
QgsApplication::authManager()->getCaCertsCache() );
|
||||
QgsApplication::authManager()->caCertsCache() );
|
||||
|
||||
if ( !cacertscache.contains( digest ) )
|
||||
{
|
||||
@ -492,7 +492,7 @@ void QgsAuthAuthoritiesEditor::btnRemoveCa_clicked()
|
||||
}
|
||||
|
||||
QMap<QString, QSslCertificate> mappedcerts(
|
||||
QgsApplication::authManager()->getMappedDatabaseCAs() );
|
||||
QgsApplication::authManager()->mappedDatabaseCAs() );
|
||||
|
||||
if ( !mappedcerts.contains( digest ) )
|
||||
{
|
||||
@ -687,7 +687,7 @@ void QgsAuthAuthoritiesEditor::btnCaFile_clicked()
|
||||
|
||||
if ( dlg->certTrustPolicy() != QgsAuthCertUtils::DefaultTrust )
|
||||
{
|
||||
QList<QSslCertificate> certs( QgsApplication::authManager()->getExtraFileCAs() );
|
||||
QList<QSslCertificate> certs( QgsApplication::authManager()->extraFileCAs() );
|
||||
Q_FOREACH ( const QSslCertificate &cert, certs )
|
||||
{
|
||||
if ( !QgsApplication::authManager()->storeCertTrustPolicy( cert, dlg->certTrustPolicy() ) )
|
||||
|
@ -80,7 +80,7 @@ QgsAuthCertInfo::QgsAuthCertInfo( const QSslCertificate &cert,
|
||||
connect( treeHierarchy, &QTreeWidget::currentItemChanged,
|
||||
this, &QgsAuthCertInfo::currentCertItemChanged );
|
||||
|
||||
mCaCertsCache = QgsApplication::authManager()->getCaCertsCache();
|
||||
mCaCertsCache = QgsApplication::authManager()->caCertsCache();
|
||||
|
||||
setUpCertDetailsTree();
|
||||
|
||||
@ -266,7 +266,7 @@ void QgsAuthCertInfo::setCertHierarchy()
|
||||
mDefaultItemForeground = item->foreground( 0 );
|
||||
}
|
||||
|
||||
decorateCertTreeItem( cert, QgsApplication::authManager()->getCertificateTrustPolicy( cert ), item );
|
||||
decorateCertTreeItem( cert, QgsApplication::authManager()->certificateTrustPolicy( cert ), item );
|
||||
|
||||
item->setFirstColumnSpanned( true );
|
||||
if ( !previtem )
|
||||
@ -291,7 +291,7 @@ void QgsAuthCertInfo::updateCurrentCertInfo( int chainindx )
|
||||
|
||||
if ( !mCurrentQCert.isNull() )
|
||||
{
|
||||
QgsAuthCertUtils::CertTrustPolicy trustpolicy( QgsApplication::authManager()->getCertificateTrustPolicy( mCurrentQCert ) );
|
||||
QgsAuthCertUtils::CertTrustPolicy trustpolicy( QgsApplication::authManager()->certificateTrustPolicy( mCurrentQCert ) );
|
||||
mCurrentTrustPolicy = trustpolicy;
|
||||
|
||||
cmbbxTrust->setTrustPolicy( trustpolicy );
|
||||
|
@ -66,7 +66,7 @@ QgsAuthIdentitiesEditor::QgsAuthIdentitiesEditor( QWidget *parent )
|
||||
connect( btnViewRefresh, &QAbstractButton::clicked, this, &QgsAuthIdentitiesEditor::refreshIdentitiesView );
|
||||
|
||||
btnGroupByOrg->setChecked( false );
|
||||
QVariant sortbyval = QgsApplication::authManager()->getAuthSetting( QStringLiteral( "identitiessortby" ), QVariant( false ) );
|
||||
QVariant sortbyval = QgsApplication::authManager()->authSetting( QStringLiteral( "identitiessortby" ), QVariant( false ) );
|
||||
if ( !sortbyval.isNull() )
|
||||
btnGroupByOrg->setChecked( sortbyval.toBool() );
|
||||
|
||||
@ -117,7 +117,7 @@ void QgsAuthIdentitiesEditor::populateIdentitiesView()
|
||||
removeChildren_( mRootCertIdentItem );
|
||||
|
||||
populateIdentitiesSection( mRootCertIdentItem,
|
||||
QgsApplication::authManager()->getCertIdentities(),
|
||||
QgsApplication::authManager()->certIdentities(),
|
||||
QgsAuthIdentitiesEditor::CertIdentity );
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ void QgsAuthIdentitiesEditor::showCertInfo( QTreeWidgetItem *item )
|
||||
return;
|
||||
}
|
||||
|
||||
QSslCertificate cert( QgsApplication::authManager()->getCertIdentity( digest ) );
|
||||
QSslCertificate cert( QgsApplication::authManager()->certIdentity( digest ) );
|
||||
|
||||
QgsAuthCertInfoDialog *dlg = new QgsAuthCertInfoDialog( cert, false, this );
|
||||
dlg->setWindowModality( Qt::WindowModal );
|
||||
|
@ -64,7 +64,7 @@ QgsAuthServersEditor::QgsAuthServersEditor( QWidget *parent )
|
||||
connect( btnViewRefresh, &QAbstractButton::clicked, this, &QgsAuthServersEditor::refreshSslConfigsView );
|
||||
|
||||
btnGroupByOrg->setChecked( false );
|
||||
QVariant sortbyval = QgsApplication::authManager()->getAuthSetting( QStringLiteral( "serverssortby" ), QVariant( false ) );
|
||||
QVariant sortbyval = QgsApplication::authManager()->authSetting( QStringLiteral( "serverssortby" ), QVariant( false ) );
|
||||
if ( !sortbyval.isNull() )
|
||||
btnGroupByOrg->setChecked( sortbyval.toBool() );
|
||||
|
||||
@ -116,7 +116,7 @@ void QgsAuthServersEditor::populateSslConfigsView()
|
||||
removeChildren_( mRootSslConfigItem );
|
||||
|
||||
populateSslConfigsSection( mRootSslConfigItem,
|
||||
QgsApplication::authManager()->getSslCertCustomConfigs(),
|
||||
QgsApplication::authManager()->sslCertCustomConfigs(),
|
||||
QgsAuthServersEditor::ServerConfig );
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@ void QgsAuthServersEditor::btnEditServer_clicked()
|
||||
return;
|
||||
}
|
||||
|
||||
QgsAuthConfigSslServer config( QgsApplication::authManager()->getSslCertCustomConfig( digest, hostport ) );
|
||||
QgsAuthConfigSslServer config( QgsApplication::authManager()->sslCertCustomConfig( digest, hostport ) );
|
||||
QSslCertificate cert( config.sslCertificate() );
|
||||
|
||||
QgsAuthSslConfigDialog *dlg = new QgsAuthSslConfigDialog( this, cert, hostport );
|
||||
|
@ -250,7 +250,7 @@ void QgsAuthSslConfigWidget::setSslCertificate( const QSslCertificate &cert, con
|
||||
|
||||
QString sha( QgsAuthCertUtils::shaHexForCert( cert ) );
|
||||
QgsAuthConfigSslServer config(
|
||||
QgsApplication::authManager()->getSslCertCustomConfig( sha, hostport.isEmpty() ? sslHost() : hostport ) );
|
||||
QgsApplication::authManager()->sslCertCustomConfig( sha, hostport.isEmpty() ? sslHost() : hostport ) );
|
||||
|
||||
emit certFoundInAuthDatabase( !config.isNull() );
|
||||
|
||||
|
@ -133,7 +133,7 @@ QgsAuthSslImportDialog::QgsAuthSslImportDialog( QWidget *parent )
|
||||
this, &QgsAuthSslImportDialog::widgetReadyToSaveChanged );
|
||||
wdgtSslConfig->setEnabled( false );
|
||||
|
||||
mTrustedCAs = QgsApplication::authManager()->getTrustedCaCertsCache();
|
||||
mTrustedCAs = QgsApplication::authManager()->trustedCaCertsCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ QgsAuthTrustedCAsDialog::QgsAuthTrustedCAsDialog( QWidget *parent,
|
||||
|
||||
|
||||
btnGroupByOrg->setChecked( false );
|
||||
QVariant sortbyval = QgsApplication::authManager()->getAuthSetting( QStringLiteral( "trustedcasortby" ), QVariant( false ) );
|
||||
QVariant sortbyval = QgsApplication::authManager()->authSetting( QStringLiteral( "trustedcasortby" ), QVariant( false ) );
|
||||
if ( !sortbyval.isNull() )
|
||||
btnGroupByOrg->setChecked( sortbyval.toBool() );
|
||||
|
||||
@ -111,7 +111,7 @@ void QgsAuthTrustedCAsDialog::populateCaCertsView()
|
||||
|
||||
if ( mTrustedCAs.isEmpty() )
|
||||
{
|
||||
mTrustedCAs = QgsApplication::authManager()->getTrustedCaCerts();
|
||||
mTrustedCAs = QgsApplication::authManager()->trustedCaCerts();
|
||||
}
|
||||
|
||||
populateCaCertsSection( mRootCaSecItem, mTrustedCAs, QgsAuthTrustedCAsDialog::CaCert );
|
||||
@ -216,7 +216,7 @@ void QgsAuthTrustedCAsDialog::showCertInfo( QTreeWidgetItem *item )
|
||||
QString digest( item->data( 0, Qt::UserRole ).toString() );
|
||||
|
||||
QMap<QString, QPair<QgsAuthCertUtils::CaCertSource, QSslCertificate> > cacertscache(
|
||||
QgsApplication::authManager()->getCaCertsCache() );
|
||||
QgsApplication::authManager()->caCertsCache() );
|
||||
|
||||
if ( !cacertscache.contains( digest ) )
|
||||
{
|
||||
|
@ -118,13 +118,13 @@ class TestQgsAuthManager(unittest.TestCase):
|
||||
self.assertTrue(self.authm.rebuildTrustedCaCertsCache(), m)
|
||||
|
||||
def trusted_ca_certs():
|
||||
tr_certs = self.authm.getTrustedCaCerts()
|
||||
tr_certs = self.authm.trustedCaCerts()
|
||||
m = 'Trusted authorities cache is empty'
|
||||
self.assertIsNotNone(tr_certs, m)
|
||||
return tr_certs
|
||||
|
||||
msg = 'No system root CAs'
|
||||
self.assertIsNotNone(self.authm.getSystemRootCAs())
|
||||
self.assertIsNotNone(self.authm.systemRootCAs())
|
||||
|
||||
# TODO: add more tests
|
||||
full_chain = 'chains_subissuer-issuer-root_issuer2-root2.pem'
|
||||
@ -333,10 +333,10 @@ class TestQgsAuthManager(unittest.TestCase):
|
||||
self.authm.existsSslCertCustomConfig(cert_sha, hostport), msg)
|
||||
|
||||
msg = 'Could not verify SSL config in all configs'
|
||||
self.assertIsNotNone(self.authm.getSslCertCustomConfigs(), msg)
|
||||
self.assertIsNotNone(self.authm.sslCertCustomConfigs(), msg)
|
||||
|
||||
msg = 'Could not retrieve SSL config'
|
||||
config2 = self.authm.getSslCertCustomConfig(cert_sha, hostport)
|
||||
config2 = self.authm.sslCertCustomConfig(cert_sha, hostport)
|
||||
""":type: QgsAuthConfigSslServer"""
|
||||
self.assertFalse(config2.isNull(), msg)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user