1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2007, 2008, 2010 Andreas Hartmetz <ahartmetz@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef _INCLUDE_KSSLCERTIFICATEMANAGER_H
9#define _INCLUDE_KSSLCERTIFICATEMANAGER_H
10
11#include <QDate>
12#include <QSslCertificate>
13#include <QSslError>
14#include <QString>
15#include <QStringList>
16
17#include "kiocore_export.h"
18
19#include <memory>
20
21class QDBusArgument;
22class KSslCertificateRulePrivate;
23class KSslCertificateManagerPrivate;
24
25/*!
26 * \class KSslCertificateRule
27 * \inheaderfile KSslCertificateManager
28 * \inmodule KIOCore
29 *
30 * Certificate rule.
31 */
32class KIOCORE_EXPORT KSslCertificateRule
33{
34public:
35 /*!
36 *
37 */
38 KSslCertificateRule(const QSslCertificate &cert = QSslCertificate(), const QString &hostName = QString());
39 KSslCertificateRule(const KSslCertificateRule &other);
40 ~KSslCertificateRule();
41 KSslCertificateRule &operator=(const KSslCertificateRule &other);
42
43 /*!
44 *
45 */
46 QSslCertificate certificate() const;
47
48 /*!
49 *
50 */
51 QString hostName() const;
52
53 /*!
54 *
55 */
56 void setExpiryDateTime(const QDateTime &dateTime);
57
58 /*!
59 *
60 */
61 QDateTime expiryDateTime() const;
62
63 /*!
64 *
65 */
66 void setRejected(bool rejected);
67
68 /*!
69 *
70 */
71 bool isRejected() const;
72 /*!
73 * Returns whether \a error is ignored for this certificate.
74 * \since 5.64
75 */
76 bool isErrorIgnored(QSslError::SslError error) const;
77 /*!
78 * Set the ignored errors for this certificate.
79 * \since 5.64
80 */
81 void setIgnoredErrors(const QList<QSslError> &errors);
82 /*!
83 * Set the ignored errors for this certificate.
84 * \since 5.64
85 */
86 void setIgnoredErrors(const QList<QSslError::SslError> &errors);
87 QList<QSslError::SslError> ignoredErrors() const;
88 /*!
89 * Filter out errors that are already ignored.
90 * \since 5.64
91 */
92 QList<QSslError> filterErrors(const QList<QSslError> &errors) const;
93
94private:
95 std::unique_ptr<KSslCertificateRulePrivate> const d;
96};
97
98/*!
99 * \class KSslCertificateManager
100 * \inmodule KIOCore
101 *
102 * Certificate manager.
103 */
104class KIOCORE_EXPORT KSslCertificateManager
105{
106public:
107 /*!
108 *
109 */
110 static KSslCertificateManager *self();
111
112 // TODO: the rule functions are not working if there is no DBus with a working kiod
113 /*!
114 *
115 */
116 void setRule(const KSslCertificateRule &rule);
117
118 /*!
119 *
120 */
121 void clearRule(const KSslCertificateRule &rule);
122
123 /*!
124 *
125 */
126 void clearRule(const QSslCertificate &cert, const QString &hostName);
127
128 /*!
129 *
130 */
131 KSslCertificateRule rule(const QSslCertificate &cert, const QString &hostName) const;
132
133 /*!
134 *
135 */
136 QList<QSslCertificate> caCertificates() const;
137
138 /*!
139 * Returns the subset of \a errors that cannot be ignored, ie. that is considered fatal.
140 * \since 5.64
141 */
142 static QList<QSslError> nonIgnorableErrors(const QList<QSslError> &errors);
143
144private:
145 friend class KSslCertificateManagerContainer;
146 friend class KSslCertificateManagerPrivate;
147 KIOCORE_NO_EXPORT KSslCertificateManager();
148 KIOCORE_NO_EXPORT ~KSslCertificateManager();
149
150 std::unique_ptr<KSslCertificateManagerPrivate> d;
151};
152
153#endif
154

source code of kio/src/core/ksslcertificatemanager.h