diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-21 21:29:30 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-21 21:29:30 +0200 |
| commit | 6ef3d6a41f07a2f43a9b69f4e75adbffe634ea09 (patch) | |
| tree | 791ad53823e47ecff837ec6004aa80c8fb1e1445 /src/ssltrust.cpp | |
| parent | 6225064a008eccb9099ed2db49dad04c5f6d0550 (diff) | |
Adds option for manually trusting a TLS server.
Diffstat (limited to 'src/ssltrust.cpp')
| -rw-r--r-- | src/ssltrust.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ssltrust.cpp b/src/ssltrust.cpp index f35988e..7ccdf9c 100644 --- a/src/ssltrust.cpp +++ b/src/ssltrust.cpp @@ -47,6 +47,27 @@ void SslTrust::save(QSettings &settings) const settings.endArray(); } +bool SslTrust::addTrust(const QUrl &url, const QSslCertificate &certificate) +{ + if(certificate.isNull()) + return false; + if(auto host_or_none = trusted_hosts.get(url.host()); host_or_none) + { + return false; + } + else + { + TrustedHost host; + host.host_name = url.host(); + host.trusted_at = QDateTime::currentDateTime(); + host.public_key = certificate.publicKey(); + + bool ok = trusted_hosts.insert(host); + assert(ok); + return true; + } +} + bool SslTrust::isTrusted(QUrl const & url, const QSslCertificate &certificate) { return (getTrust(url, certificate) == Trusted); @@ -54,6 +75,9 @@ bool SslTrust::isTrusted(QUrl const & url, const QSslCertificate &certificate) SslTrust::TrustStatus SslTrust::getTrust(const QUrl &url, const QSslCertificate &certificate) { + if(certificate.isNull()) + return Untrusted; + if(trust_level == TrustEverything) return Trusted; |
