KIO

ksslcertificatemanager.h
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 2007, 2008, 2010 Andreas Hartmetz <[email protected]>
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 "ktcpsocket.h" // TODO KF6 remove include
12 
13 #include <QDate>
14 #include <QSslCertificate>
15 #include <QSslError>
16 #include <QString>
17 #include <QStringList>
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());
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 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 64)
42  /** @deprecated since 5.64, use the QSslError variant. */
43  KIOCORE_DEPRECATED_VERSION(5, 64, "Use KSslCertificateRule::isErrorIgnored(QSslError::SslError)")
44  bool isErrorIgnored(KSslError::Error error) const;
45 #endif
46  /**
47  * Returns whether @p error is ignored for this certificate.
48  * @since 5.64
49  */
50  bool isErrorIgnored(QSslError::SslError error) const;
51 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 64)
52  /** @deprecated since 5.64, use the QSslError variant. */
53  KIOCORE_DEPRECATED_VERSION(5, 64, "Use KSslCertificateRule::setIgnoredErrors(const QList<QSslError> &)")
54  void setIgnoredErrors(const QList<KSslError::Error> &errors);
55  /** @deprecated since 5.64, use the QSslError variant. */
56  KIOCORE_DEPRECATED_VERSION(5, 64, "Use KSslCertificateRule::setIgnoredErrors(const QList<QSslError> &)")
57  void setIgnoredErrors(const QList<KSslError> &errors);
58 #endif
59  /**
60  * Set the ignored errors for this certificate.
61  * @since 5.64
62  */
63  void setIgnoredErrors(const QList<QSslError> &errors);
64  /**
65  * Set the ignored errors for this certificate.
66  * @since 5.64
67  */
68  void setIgnoredErrors(const QList<QSslError::SslError> &errors);
69 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 64)
70  QList<KSslError::Error> ignoredErrors() const;
71 #else
72  QList<QSslError::SslError> ignoredErrors() const;
73 #endif
74 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 64)
75  /** @deprecated since 5.64, use the QSslError variant. */
76  KIOCORE_DEPRECATED_VERSION(5, 64, "Use KSslCertificateRule::filterErrors(const QList<QSslError> &)")
77  QList<KSslError::Error> filterErrors(const QList<KSslError::Error> &errors) const;
78  /** @deprecated since 5.64, use the QSslError variant. */
79  KIOCORE_DEPRECATED_VERSION(5, 64, "Use KSslCertificateRule::filterErrors(const QList<QSslError> &)")
80  QList<KSslError> filterErrors(const QList<KSslError> &errors) const;
81 #endif
82  /**
83  * Filter out errors that are already ignored.
84  * @since 5.64
85  */
86  QList<QSslError> filterErrors(const QList<QSslError> &errors) const;
87 
88 private:
89  friend QDBusArgument &operator<<(QDBusArgument &argument, const KSslCertificateRule &rule); // TODO KF6 remove
90  friend class KSSLD; // TODO KF6 remove
91  std::unique_ptr<KSslCertificateRulePrivate> const d;
92 };
93 
94 // ### document this too... :/
95 /** Certificate manager. */
96 class KIOCORE_EXPORT KSslCertificateManager
97 {
98 public:
99  static KSslCertificateManager *self();
100  void setRule(const KSslCertificateRule &rule);
101  void clearRule(const KSslCertificateRule &rule);
102  void clearRule(const QSslCertificate &cert, const QString &hostName);
103  KSslCertificateRule rule(const QSslCertificate &cert, const QString &hostName) const;
104 
105 #if KIOCORE_ENABLE_DEPRECATED_SINCE(4, 6)
106  /** @deprecated Since 4.6, use caCertificates() instead */
107  KIOCORE_DEPRECATED_VERSION(4, 6, "Use KSslCertificateManager::caCertificates()")
108  QList<QSslCertificate> rootCertificates() const
109  {
110  return caCertificates();
111  }
112 #endif
113 
114  QList<QSslCertificate> caCertificates() const;
115 
116 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 64)
117  /** @deprecated since 5.64, use the corresponding QSslError variant. */
118  KIOCORE_DEPRECATED_VERSION(5, 64, "Use KSslCertificateManager::nonIgnorableErrors(const QList<QSslError> &)")
119  static QList<KSslError> nonIgnorableErrors(const QList<KSslError> &errors);
120  /** @deprecated since 5.64, use the corresponding QSslError variant. */
121  KIOCORE_DEPRECATED_VERSION(5, 64, "Use KSslCertificateManager::nonIgnorableErrors(const QList<QSslError> &)")
122  static QList<KSslError::Error> nonIgnorableErrors(const QList<KSslError::Error> &errors);
123 #endif
124  /**
125  * Returns the subset of @p errors that cannot be ignored, ie. that is considered fatal.
126  * @since 5.64
127  */
128  static QList<QSslError> nonIgnorableErrors(const QList<QSslError> &errors);
129 
130 private:
131  friend class KSslCertificateManagerContainer;
132  friend class KSslCertificateManagerPrivate;
135 
136  std::unique_ptr<KSslCertificateManagerPrivate> d;
137 };
138 
139 #endif
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
To be replaced by QSslError.
Definition: ktcpsocket.h:103
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:00:36 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.