| 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 | |
| 17 | class KSslCertificateRulePrivate |
| 18 | { |
| 19 | public: |
| 20 | QSslCertificate certificate; |
| 21 | QString hostName; |
| 22 | bool isRejected; |
| 23 | QDateTime expiryDateTime; |
| 24 | QList<QSslError::SslError> ignoredErrors; |
| 25 | }; |
| 26 | |
| 27 | struct 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 | |
| 49 | class OrgKdeKSSLDInterface; // aka org::kde::KSSLDInterface |
| 50 | namespace org |
| 51 | { |
| 52 | namespace kde |
| 53 | { |
| 54 | typedef ::OrgKdeKSSLDInterface KSSLDInterface; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | class KSslCertificateManagerPrivate |
| 59 | { |
| 60 | public: |
| 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 | |
| 82 | #ifdef WITH_QTDBUS |
| 83 | org::kde::KSSLDInterface *iface; |
| 84 | #endif |
| 85 | |
| 86 | QList<QSslCertificate> defaultCaCertificates; |
| 87 | |
| 88 | // for use in setAllCertificates() only |
| 89 | QSet<QByteArray> knownCerts; |
| 90 | QMutex certListMutex; |
| 91 | bool isCertListLoaded; |
| 92 | QString userCertDir; |
| 93 | }; |
| 94 | |
| 95 | // don't export KSslCertificateManagerPrivate to avoid unnecessary symbols |
| 96 | KIOCORE_EXPORT QList<KSslCaCertificate> _allKsslCaCertificates(KSslCertificateManager *cm); |
| 97 | KIOCORE_EXPORT void _setAllKsslCaCertificates(KSslCertificateManager *cm, const QList<KSslCaCertificate> &certsIn); |
| 98 | |
| 99 | #endif // KSSLCERTIFICATEMANAGER_P_H |
| 100 |
