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 | |
21 | class QDBusArgument; |
22 | class KSslCertificateRulePrivate; |
23 | class KSslCertificateManagerPrivate; |
24 | |
25 | // ### document this... :/ |
26 | /** Certificate rule. */ |
27 | class KIOCORE_EXPORT KSslCertificateRule |
28 | { |
29 | public: |
30 | KSslCertificateRule(const QSslCertificate &cert = QSslCertificate(), const QString &hostName = QString()); |
31 | KSslCertificateRule(const KSslCertificateRule &other); |
32 | ~KSslCertificateRule(); |
33 | KSslCertificateRule &operator=(const KSslCertificateRule &other); |
34 | |
35 | QSslCertificate certificate() const; |
36 | QString hostName() const; |
37 | void setExpiryDateTime(const QDateTime &dateTime); |
38 | QDateTime expiryDateTime() const; |
39 | void setRejected(bool rejected); |
40 | bool isRejected() const; |
41 | /** |
42 | * Returns whether @p error is ignored for this certificate. |
43 | * @since 5.64 |
44 | */ |
45 | bool isErrorIgnored(QSslError::SslError error) const; |
46 | /** |
47 | * Set the ignored errors for this certificate. |
48 | * @since 5.64 |
49 | */ |
50 | void setIgnoredErrors(const QList<QSslError> &errors); |
51 | /** |
52 | * Set the ignored errors for this certificate. |
53 | * @since 5.64 |
54 | */ |
55 | void setIgnoredErrors(const QList<QSslError::SslError> &errors); |
56 | QList<QSslError::SslError> ignoredErrors() const; |
57 | /** |
58 | * Filter out errors that are already ignored. |
59 | * @since 5.64 |
60 | */ |
61 | QList<QSslError> filterErrors(const QList<QSslError> &errors) const; |
62 | |
63 | private: |
64 | std::unique_ptr<KSslCertificateRulePrivate> const d; |
65 | }; |
66 | |
67 | // ### document this too... :/ |
68 | /** Certificate manager. */ |
69 | class KIOCORE_EXPORT KSslCertificateManager |
70 | { |
71 | public: |
72 | static KSslCertificateManager *self(); |
73 | void setRule(const KSslCertificateRule &rule); |
74 | void clearRule(const KSslCertificateRule &rule); |
75 | void clearRule(const QSslCertificate &cert, const QString &hostName); |
76 | KSslCertificateRule rule(const QSslCertificate &cert, const QString &hostName) const; |
77 | |
78 | QList<QSslCertificate> caCertificates() const; |
79 | |
80 | /** |
81 | * Returns the subset of @p errors that cannot be ignored, ie. that is considered fatal. |
82 | * @since 5.64 |
83 | */ |
84 | static QList<QSslError> nonIgnorableErrors(const QList<QSslError> &errors); |
85 | |
86 | private: |
87 | friend class KSslCertificateManagerContainer; |
88 | friend class KSslCertificateManagerPrivate; |
89 | KIOCORE_NO_EXPORT KSslCertificateManager(); |
90 | KIOCORE_NO_EXPORT ~KSslCertificateManager(); |
91 | |
92 | std::unique_ptr<KSslCertificateManagerPrivate> d; |
93 | }; |
94 | |
95 | #endif |
96 | |