aboutsummaryrefslogtreecommitdiff
path: root/src/ssltrust.hpp
blob: 62d498572c39e786c2570dcc856733ccdb0bfd6f (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
#ifndef SSLTRUST_HPP
#define SSLTRUST_HPP

#include <QSslCertificate>
#include <QSslKey>
#include <QSettings>

#include "trustedhostcollection.hpp"

struct SslTrust
{
    enum TrustLevel {
        TrustOnFirstUse = 0, // default
        TrustEverything = 1, // not recommended
        TrustNoOne      = 2, // approve every fingerprint by hand
    };

    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;

    bool isTrusted(QUrl const & url, QSslCertificate const & certificate);
};

#endif // SSLTRUST_HPP