Skip to content
Snippets Groups Projects
Verified Commit 1a485045 authored by Tobias Triffterer's avatar Tobias Triffterer :house_with_garden:
Browse files

Wrapper Class for Certificate Resources

This class pulls all CA certificate files from the Qt resource system
after making sure these resources are properly initialized, which is
required as they are part of a static library.
parent 2447aed2
No related branches found
No related tags found
No related merge requests found
Pipeline #3149 passed with stage
in 22 seconds
/**
* @file cacertificates.h
*
* @author Tobias Triffterer
*
* @brief Retrieve Certificates from Qt Resources
*
* Rutherford Experiment Lab Course Online
* Copyright © 2021 Ruhr-Universität Bochum, Institut für Experimentalphysik I
* https://www.ep1.ruhr-uni-bochum.de/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**/
#include <QDir>
#include "cacertificates.h"
static void initResourcesOutsideNamespace()
{
#ifdef LIBFP311ONLINE_LOAD_DEVEL_CERT_RESOURCE
Q_INIT_RESOURCE(devel_cert);
#endif
}
using namespace Fp311Online;
QList<QSslCertificate> CaCertificates::getCaCertificatesFromResource()
{
static bool initializedResource = false;
if (!initializedResource) {
initResourcesOutsideNamespace();
initializedResource = true;
}
return QSslCertificate::fromPath(
QStringLiteral(":/crypto/*.pem"),
QSsl::Pem,
QRegExp::Wildcard
);
}
/**
* @file cacertificates.h
*
* @author Tobias Triffterer
*
* @brief Retrieve Certificates from Qt Resources
*
* Rutherford Experiment Lab Course Online
* Copyright © 2021 Ruhr-Universität Bochum, Institut für Experimentalphysik I
* https://www.ep1.ruhr-uni-bochum.de/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**/
#ifndef LIBFP311ONLINE_CACERTIFICATES_H
#define LIBFP311ONLINE_CACERTIFICATES_H
#include <QList>
#include <QSslCertificate>
namespace Fp311Online
{
class CaCertificates
{
public:
static QList<QSslCertificate> getCaCertificatesFromResource();
CaCertificates() = delete;
~CaCertificates() = delete;
CaCertificates(const CaCertificates& other) = delete;
CaCertificates(CaCertificates&& other) = delete;
CaCertificates& operator=(const CaCertificates& other) = delete;
CaCertificates& operator=(CaCertificates&& other) = delete;
};
}
#endif // LIBFP311ONLINE_CACERTIFICATES_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment