refactor: move TlsCertificate::getCertKeyLength -> static TlsUtility::getCertKeyLength
This commit is contained in:
@ -264,12 +264,11 @@ bool SettingsDialog::isClientMode() const
|
||||
|
||||
void SettingsDialog::updateKeyLengthOnFile(const QString &path)
|
||||
{
|
||||
TlsCertificate ssl;
|
||||
if (!QFile(path).exists()) {
|
||||
qFatal("tls certificate file not found: %s", qUtf8Printable(path));
|
||||
}
|
||||
|
||||
auto length = ssl.getCertKeyLength(path);
|
||||
auto length = TlsUtility::getCertKeyLength(path);
|
||||
auto labelIcon = QPixmap(QIcon::fromTheme(QIcon::ThemeIcon::SecurityLow).pixmap(24, 24));
|
||||
if (length == 2048)
|
||||
labelIcon = QPixmap(QIcon::fromTheme(QStringLiteral("security-medium")).pixmap(24, 24));
|
||||
|
||||
@ -47,8 +47,3 @@ bool TlsCertificate::generateFingerprint(const QString &certificateFilename) con
|
||||
db.addTrusted(deskflow::pemFileCertFingerprint(certPath, Fingerprint::Type::SHA256));
|
||||
return db.write(Settings::tlsLocalDb());
|
||||
}
|
||||
|
||||
int TlsCertificate::getCertKeyLength(const QString &path) const
|
||||
{
|
||||
return deskflow::getCertLength(path.toStdString());
|
||||
}
|
||||
|
||||
@ -18,5 +18,4 @@ public:
|
||||
|
||||
bool generateCertificate(const QString &path, int keyLength) const;
|
||||
bool generateFingerprint(const QString &certificateFilename) const;
|
||||
int getCertKeyLength(const QString &path) const;
|
||||
};
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
#include "TlsCertificate.h"
|
||||
#include "common/Settings.h"
|
||||
#include "net/SecureUtils.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QSslCertificate>
|
||||
@ -64,6 +65,11 @@ bool TlsUtility::isCertValid(const QString &certPath)
|
||||
return true;
|
||||
}
|
||||
|
||||
int TlsUtility::getCertKeyLength(const QString &certPath)
|
||||
{
|
||||
return deskflow::getCertLength(certPath.toStdString());
|
||||
}
|
||||
|
||||
bool TlsUtility::generateCertificate() const
|
||||
{
|
||||
qDebug(
|
||||
|
||||
@ -36,6 +36,13 @@ public:
|
||||
*/
|
||||
static bool isCertValid(const QString &certPath = Settings::value(Settings::Security::Certificate).toString());
|
||||
|
||||
/**
|
||||
* @brief Get the lenght of a key
|
||||
* @param certPath path of the file to check, when unset will use the value of Settings::Security::Certificate
|
||||
* @return the bitsize of the key
|
||||
*/
|
||||
static int getCertKeyLength(const QString &certPath = Settings::value(Settings::Security::Certificate).toString());
|
||||
|
||||
private:
|
||||
TlsCertificate m_certificate;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user