dbhub: Add list of CA certificates and restructure code

Change the layout of the preferences dialog a bit.

Remove the server selection combo box from the preferences dialog as it
will probably never be required. The way we do logins using certificates
kind of makes this obsolete, I think.

Restructure the whole remote code a little bit. Also add helper
functions here and there.

Show a list of our the CA certificates built into the application in the
preferences dialog. This list is read only of course but still
informative as it tells the user which sites are supported ny DB4S.
This commit is contained in:
Martin Kleusberg
2016-11-01 19:45:42 +01:00
parent e9894b47fa
commit 6283f97598
9 changed files with 284 additions and 212 deletions

View File

@@ -14,25 +14,6 @@ RemoteDatabase::RemoteDatabase() :
m_manager(new QNetworkAccessManager),
m_progress(nullptr),
m_currentReply(nullptr)
{
// Load settings and set up some more stuff while doing so
reloadSettings();
// TODO Add support for proxies here
// Set up signals
connect(m_manager, &QNetworkAccessManager::finished, this, &RemoteDatabase::gotReply);
connect(m_manager, &QNetworkAccessManager::encrypted, this, &RemoteDatabase::gotEncrypted);
connect(m_manager, &QNetworkAccessManager::sslErrors, this, &RemoteDatabase::gotError);
}
RemoteDatabase::~RemoteDatabase()
{
delete m_manager;
delete m_progress;
}
void RemoteDatabase::reloadSettings()
{
// Set up SSL configuration
m_sslConfiguration = QSslConfiguration::defaultConfiguration();
@@ -59,6 +40,25 @@ void RemoteDatabase::reloadSettings()
QSslKey clientKey(&fileClientKey, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "password");
fileClientKey.close();
m_sslConfiguration.setPrivateKey(clientKey);
// Load settings and set up some more stuff while doing so
reloadSettings();
// Set up signals
connect(m_manager, &QNetworkAccessManager::finished, this, &RemoteDatabase::gotReply);
connect(m_manager, &QNetworkAccessManager::encrypted, this, &RemoteDatabase::gotEncrypted);
connect(m_manager, &QNetworkAccessManager::sslErrors, this, &RemoteDatabase::gotError);
}
RemoteDatabase::~RemoteDatabase()
{
delete m_manager;
delete m_progress;
}
void RemoteDatabase::reloadSettings()
{
// TODO Add support for proxies here
}
void RemoteDatabase::fetchDatabase(const QString& url)
@@ -201,3 +201,9 @@ void RemoteDatabase::updateProgress(qint64 bytesReceived, qint64 bytesTotal)
m_progress->hide();
}
}
const QList<QSslCertificate>& RemoteDatabase::caCertificates() const
{
static QList<QSslCertificate> certs = m_sslConfiguration.caCertificates();
return certs;
}