2024-07-26 22:53:52 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-11-22 15:06:20 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2024-07-26 22:53:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-11-22 15:06:20 +00:00
|
|
|
#include <common/Settings.h>
|
2024-07-26 22:53:52 +00:00
|
|
|
|
2024-08-07 14:05:18 +00:00
|
|
|
#include <QObject>
|
|
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
namespace deskflow::gui {
|
2024-07-26 22:53:52 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
class TlsUtility : public QObject
|
|
|
|
|
{
|
2024-08-07 14:05:18 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
2024-07-26 22:53:52 +00:00
|
|
|
public:
|
2025-03-07 00:27:29 +00:00
|
|
|
explicit TlsUtility(QObject *parent = nullptr);
|
2024-08-07 14:05:18 +00:00
|
|
|
|
2025-11-22 17:35:41 +00:00
|
|
|
static bool generateCertificate();
|
2024-07-26 22:53:52 +00:00
|
|
|
|
|
|
|
|
/**
|
2025-11-22 13:32:00 +00:00
|
|
|
* @brief Checks the settings values Settings::Security::TlsEnabled
|
|
|
|
|
* @return true when tls is enabled
|
2024-07-26 22:53:52 +00:00
|
|
|
*/
|
2025-11-22 13:32:00 +00:00
|
|
|
static bool isEnabled();
|
2024-07-26 22:53:52 +00:00
|
|
|
|
2025-11-22 15:06:20 +00:00
|
|
|
/**
|
|
|
|
|
* @brief isCertValid
|
|
|
|
|
* @param certPath the path of the file to check, when not set uses Settings::Security::Certificate value
|
|
|
|
|
* @return true if the certificate is valid
|
|
|
|
|
*/
|
|
|
|
|
static bool isCertValid(const QString &certPath = Settings::value(Settings::Security::Certificate).toString());
|
|
|
|
|
|
2025-11-22 15:29:47 +00:00
|
|
|
/**
|
|
|
|
|
* @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());
|
|
|
|
|
|
2025-11-22 15:51:39 +00:00
|
|
|
/**
|
|
|
|
|
* @brief get the SHA256 fingerprint of a certificatefile.
|
|
|
|
|
* @param certPath path of the file to fingerprint, when not set uses the vaule of Settings::Security::Certificate
|
|
|
|
|
* @return A QByteArray of the SHA256 fingerprint of the file or empty array if invalid file is passed
|
|
|
|
|
*/
|
|
|
|
|
// clang-format off
|
|
|
|
|
static QByteArray certFingerprint(const QString &certPath = Settings::value(Settings::Security::Certificate).toString());
|
|
|
|
|
// clang-format on
|
2024-07-26 22:53:52 +00:00
|
|
|
};
|
|
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
} // namespace deskflow::gui
|