1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2010 Andreas Hartmetz <ahartmetz@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KSSLCERTIFICATEMANAGER_P_H
9#define KSSLCERTIFICATEMANAGER_P_H
10
11#include <QMutex>
12#include <QSet>
13#include <QString>
14
15#include <KConfig>
16
17class KSslCertificateRulePrivate
18{
19public:
20 QSslCertificate certificate;
21 QString hostName;
22 bool isRejected;
23 QDateTime expiryDateTime;
24 QList<QSslError::SslError> ignoredErrors;
25};
26
27struct KSslCaCertificate {
28 enum Store {
29 SystemStore = 0,
30 UserStore,
31 };
32
33 // TODO see if we can get rid of the .toHex() for storage and comparison; requires
34 // several changes in KSslCertificateManager and CaCertificatesPage!
35 KSslCaCertificate(const QSslCertificate &c, Store s, bool _isBlacklisted)
36 : cert(c)
37 , certHash(c.digest().toHex())
38 , store(s)
39 , isBlacklisted(_isBlacklisted)
40 {
41 }
42
43 QSslCertificate cert;
44 QByteArray certHash;
45 Store store;
46 bool isBlacklisted;
47};
48
49class OrgKdeKSSLDInterface; // aka org::kde::KSSLDInterface
50namespace org
51{
52namespace kde
53{
54typedef ::OrgKdeKSSLDInterface KSSLDInterface;
55}
56}
57
58class KSslCertificateManagerPrivate
59{
60public:
61 KSslCertificateManagerPrivate();
62 ~KSslCertificateManagerPrivate();
63
64 static KSslCertificateManagerPrivate *get(KSslCertificateManager *q)
65 {
66 return q->d.get();
67 }
68
69 void loadDefaultCaCertificates();
70
71 // helpers for setAllCertificates()
72 bool addCertificate(const KSslCaCertificate &in);
73 bool removeCertificate(const KSslCaCertificate &old);
74 bool updateCertificateBlacklisted(const KSslCaCertificate &cert);
75 bool setCertificateBlacklisted(const QByteArray &certHash, bool isBlacklisted);
76
77 void setAllCertificates(const QList<KSslCaCertificate> &certsIn);
78 QList<KSslCaCertificate> allCertificates() const;
79
80 KConfig config;
81 org::kde::KSSLDInterface *iface;
82
83 QList<QSslCertificate> defaultCaCertificates;
84
85 // for use in setAllCertificates() only
86 QSet<QByteArray> knownCerts;
87 QMutex certListMutex;
88 bool isCertListLoaded;
89 QString userCertDir;
90};
91
92// don't export KSslCertificateManagerPrivate to avoid unnecessary symbols
93KIOCORE_EXPORT QList<KSslCaCertificate> _allKsslCaCertificates(KSslCertificateManager *cm);
94KIOCORE_EXPORT void _setAllKsslCaCertificates(KSslCertificateManager *cm, const QList<KSslCaCertificate> &certsIn);
95
96#endif // KSSLCERTIFICATEMANAGER_P_H
97

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