blob: 4214d8ad7bd427441a948ff2db3210a3c4695fd5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#ifndef SSLTRUST_HPP
#define SSLTRUST_HPP
#include <QSslCertificate>
#include <QSslKey>
#include <QSettings>
#include <QSslError>
#include "trustedhostcollection.hpp"
struct SslTrust
{
enum TrustLevel {
TrustOnFirstUse = 0, // default
TrustEverything = 1, // not recommended
TrustNoOne = 2, // approve every fingerprint by hand
};
enum TrustStatus {
Untrusted = 0,
Trusted = 1,
Mistrusted = 2,
};
SslTrust() = default;
SslTrust(SslTrust const &) = default;
SslTrust(SslTrust &&) = default;
SslTrust & operator=(SslTrust const &) = default;
SslTrust & operator=(SslTrust &&) = default;
TrustLevel trust_level = TrustOnFirstUse;
TrustedHostCollection trusted_hosts;
bool enable_ca = false;
void load(QSettings & settings);
void save(QSettings & settings) const;
//! Adds the certificate to the trust store. Returns `true` on success.
bool addTrust(QUrl const & url, QSslCertificate const & certificate);
bool isTrusted(QUrl const & url, QSslCertificate const & certificate);
TrustStatus getTrust(QUrl const & url, QSslCertificate const & certificate);
static bool isTrustRelated(QSslError::SslError err);
};
#endif // SSLTRUST_HPP
|