1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
5#ifndef QSSLERROR_H
6#define QSSLERROR_H
7
8#include <QtNetwork/qtnetworkglobal.h>
9#include <QtCore/qvariant.h>
10#include <QtNetwork/qsslcertificate.h>
11
12#include <memory>
13
14QT_BEGIN_NAMESPACE
15
16
17#ifndef QT_NO_SSL
18
19class QSslErrorPrivate;
20class Q_NETWORK_EXPORT QSslError
21{
22 Q_GADGET
23public:
24 enum SslError {
25 NoError,
26 UnableToGetIssuerCertificate,
27 UnableToDecryptCertificateSignature,
28 UnableToDecodeIssuerPublicKey,
29 CertificateSignatureFailed,
30 CertificateNotYetValid,
31 CertificateExpired,
32 InvalidNotBeforeField,
33 InvalidNotAfterField,
34 SelfSignedCertificate,
35 SelfSignedCertificateInChain,
36 UnableToGetLocalIssuerCertificate,
37 UnableToVerifyFirstCertificate,
38 CertificateRevoked,
39 InvalidCaCertificate,
40 PathLengthExceeded,
41 InvalidPurpose,
42 CertificateUntrusted,
43 CertificateRejected,
44 SubjectIssuerMismatch, // hostname mismatch?
45 AuthorityIssuerSerialNumberMismatch,
46 NoPeerCertificate,
47 HostNameMismatch,
48 NoSslSupport,
49 CertificateBlacklisted,
50 CertificateStatusUnknown,
51 OcspNoResponseFound,
52 OcspMalformedRequest,
53 OcspMalformedResponse,
54 OcspInternalError,
55 OcspTryLater,
56 OcspSigRequred,
57 OcspUnauthorized,
58 OcspResponseCannotBeTrusted,
59 OcspResponseCertIdUnknown,
60 OcspResponseExpired,
61 OcspStatusUnknown,
62 UnspecifiedError = -1
63 };
64 Q_ENUM(SslError)
65
66 // RVCT compiler in debug build does not like about default values in const-
67 // So as an workaround we define all constructor overloads here explicitly
68 QSslError();
69 explicit QSslError(SslError error);
70 QSslError(SslError error, const QSslCertificate &certificate);
71
72 QSslError(const QSslError &other);
73
74 void swap(QSslError &other) noexcept
75 { d.swap(u&: other.d); }
76
77 ~QSslError();
78 QSslError &operator=(QSslError &&other) noexcept { swap(other); return *this; }
79 QSslError &operator=(const QSslError &other);
80 bool operator==(const QSslError &other) const;
81 inline bool operator!=(const QSslError &other) const
82 { return !(*this == other); }
83
84 SslError error() const;
85 QString errorString() const;
86 QSslCertificate certificate() const;
87
88private:
89 // ### Qt 7: make QSslError implicitly shared
90 std::unique_ptr<QSslErrorPrivate> d;
91};
92Q_DECLARE_SHARED(QSslError)
93
94Q_NETWORK_EXPORT size_t qHash(const QSslError &key, size_t seed = 0) noexcept;
95
96#ifndef QT_NO_DEBUG_STREAM
97class QDebug;
98Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslError &error);
99Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslError::SslError &error);
100#endif
101#else
102class Q_NETWORK_EXPORT QSslError {}; // dummy class so that moc has a complete type
103#endif // QT_NO_SSL
104
105QT_END_NAMESPACE
106
107#ifndef QT_NO_SSL
108QT_DECL_METATYPE_EXTERN_TAGGED(QList<QSslError>, QList_QSslError, Q_NETWORK_EXPORT)
109#endif
110
111#endif
112

source code of qtbase/src/network/ssl/qsslerror.h