1 | /* |
---|---|
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2007, 2008 Andreas Hartmetz <ahartmetz@gmail.com> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #include "ksslerroruidata.h" |
9 | #include "ksslerroruidata_p.h" |
10 | |
11 | #include <QHostAddress> |
12 | #include <QNetworkReply> |
13 | #include <QSslCipher> |
14 | |
15 | KSslErrorUiData::KSslErrorUiData() |
16 | : d(new Private()) |
17 | { |
18 | d->usedBits = 0; |
19 | d->bits = 0; |
20 | } |
21 | |
22 | KSslErrorUiData::KSslErrorUiData(const QSslSocket *socket) |
23 | : d(new Private()) |
24 | { |
25 | d->certificateChain = socket->peerCertificateChain(); |
26 | d->sslErrors = socket->sslHandshakeErrors(); |
27 | d->ip = socket->peerAddress().toString(); |
28 | d->host = socket->peerName(); |
29 | if (socket->isEncrypted()) { |
30 | d->sslProtocol = socket->sessionCipher().protocolString(); |
31 | } |
32 | d->cipher = socket->sessionCipher().name(); |
33 | d->usedBits = socket->sessionCipher().usedBits(); |
34 | d->bits = socket->sessionCipher().supportedBits(); |
35 | } |
36 | |
37 | KSslErrorUiData::KSslErrorUiData(const QNetworkReply *reply, const QList<QSslError> &sslErrors) |
38 | : d(new Private()) |
39 | { |
40 | const auto sslConfig = reply->sslConfiguration(); |
41 | d->certificateChain = sslConfig.peerCertificateChain(); |
42 | d->sslErrors = sslErrors; |
43 | d->host = reply->request().url().host(); |
44 | d->sslProtocol = sslConfig.sessionCipher().protocolString(); |
45 | d->cipher = sslConfig.sessionCipher().name(); |
46 | d->usedBits = sslConfig.sessionCipher().usedBits(); |
47 | d->bits = sslConfig.sessionCipher().supportedBits(); |
48 | } |
49 | |
50 | KSslErrorUiData::KSslErrorUiData(const KSslErrorUiData &other) |
51 | : d(new Private(*other.d)) |
52 | { |
53 | } |
54 | |
55 | KSslErrorUiData::~KSslErrorUiData() = default; |
56 | |
57 | KSslErrorUiData &KSslErrorUiData::operator=(const KSslErrorUiData &other) |
58 | { |
59 | *d = *other.d; |
60 | return *this; |
61 | } |
62 |