Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsslconfiguration.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2014 BlackBerry Limited. All rights reserved.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6/****************************************************************************
7**
8** In addition, as a special exception, the copyright holders listed above give
9** permission to link the code of its release of Qt with the OpenSSL project's
10** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
11** same license as the original version), and distribute the linked executables.
12**
13** You must comply with the GNU General Public License version 2 in all
14** respects for all of the code used other than the "OpenSSL" code. If you
15** modify this file, you may extend this exception to your version of the file,
16** but you are not obligated to do so. If you do not wish to do so, delete
17** this exception statement from your version of this file.
18**
19****************************************************************************/
20
21#ifndef QSSLCONFIGURATION_H
22#define QSSLCONFIGURATION_H
23
24#include <QtNetwork/qtnetworkglobal.h>
25#include <QtCore/qmap.h>
26#include <QtCore/qshareddata.h>
27#include <QtNetwork/qsslsocket.h>
28#include <QtNetwork/qssl.h>
29
30#ifndef QT_NO_SSL
31
32QT_BEGIN_NAMESPACE
33
34class QSslCertificate;
35class QSslCipher;
36class QSslKey;
39class QSslDiffieHellmanParameters;
40
41class QSslConfigurationPrivate;
42class Q_NETWORK_EXPORT QSslConfiguration
43{
44public:
45 QSslConfiguration();
46 QSslConfiguration(const QSslConfiguration &other);
47 ~QSslConfiguration();
48 QSslConfiguration &operator=(QSslConfiguration &&other) noexcept { swap(other); return *this; }
49 QSslConfiguration &operator=(const QSslConfiguration &other);
50
51 void swap(QSslConfiguration &other) noexcept
52 { d.swap(other.d); }
53
54 bool operator==(const QSslConfiguration &other) const;
55 inline bool operator!=(const QSslConfiguration &other) const
56 { return !(*this == other); }
57
58 bool isNull() const;
59
60 QSsl::SslProtocol protocol() const;
61 void setProtocol(QSsl::SslProtocol protocol);
62
63 // Verification
64 QSslSocket::PeerVerifyMode peerVerifyMode() const;
65 void setPeerVerifyMode(QSslSocket::PeerVerifyMode mode);
66
67 int peerVerifyDepth() const;
68 void setPeerVerifyDepth(int depth);
69
70 // Certificate & cipher configuration
71 QList<QSslCertificate> localCertificateChain() const;
72 void setLocalCertificateChain(const QList<QSslCertificate> &localChain);
73
74 QSslCertificate localCertificate() const;
75 void setLocalCertificate(const QSslCertificate &certificate);
76
77 QSslCertificate peerCertificate() const;
78 QList<QSslCertificate> peerCertificateChain() const;
79 QSslCipher sessionCipher() const;
80 QSsl::SslProtocol sessionProtocol() const;
81
82 // Private keys, for server sockets
83 QSslKey privateKey() const;
84 void setPrivateKey(const QSslKey &key);
85
86 // Cipher settings
87 QList<QSslCipher> ciphers() const;
88 void setCiphers(const QList<QSslCipher> &ciphers);
89 void setCiphers(const QString &ciphers);
90 static QList<QSslCipher> supportedCiphers();
91
92 // Certificate Authority (CA) settings
93 QList<QSslCertificate> caCertificates() const;
94 void setCaCertificates(const QList<QSslCertificate> &certificates);
95 bool addCaCertificates(
96 const QString &path, QSsl::EncodingFormat format = QSsl::Pem,
97 QSslCertificate::PatternSyntax syntax = QSslCertificate::PatternSyntax::FixedString);
98 void addCaCertificate(const QSslCertificate &certificate);
99 void addCaCertificates(const QList<QSslCertificate> &certificates);
100
101 static QList<QSslCertificate> systemCaCertificates();
102
103 void setSslOption(QSsl::SslOption option, bool on);
104 bool testSslOption(QSsl::SslOption option) const;
105
106 QByteArray sessionTicket() const;
107 void setSessionTicket(const QByteArray &sessionTicket);
108 int sessionTicketLifeTimeHint() const;
109
110 QSslKey ephemeralServerKey() const;
111
112 // EC settings
113 QList<QSslEllipticCurve> ellipticCurves() const;
114 void setEllipticCurves(const QList<QSslEllipticCurve> &curves);
115 static QList<QSslEllipticCurve> supportedEllipticCurves();
116
117 QByteArray preSharedKeyIdentityHint() const;
118 void setPreSharedKeyIdentityHint(const QByteArray &hint);
119
120 QSslDiffieHellmanParameters diffieHellmanParameters() const;
121 void setDiffieHellmanParameters(const QSslDiffieHellmanParameters &dhparams);
122
123 QMap<QByteArray, QVariant> backendConfiguration() const;
124 void setBackendConfigurationOption(const QByteArray &name, const QVariant &value);
125 void setBackendConfiguration(const QMap<QByteArray, QVariant> &backendConfiguration = QMap<QByteArray, QVariant>());
126
127 static QSslConfiguration defaultConfiguration();
128 static void setDefaultConfiguration(const QSslConfiguration &configuration);
129
130#if QT_CONFIG(dtls) || defined(Q_QDOC)
131 bool dtlsCookieVerificationEnabled() const;
132 void setDtlsCookieVerificationEnabled(bool enable);
133
134 static QSslConfiguration defaultDtlsConfiguration();
135 static void setDefaultDtlsConfiguration(const QSslConfiguration &configuration);
136#endif // dtls
137
138 bool handshakeMustInterruptOnError() const;
139 void setHandshakeMustInterruptOnError(bool interrupt);
140
141 bool missingCertificateIsFatal() const;
142 void setMissingCertificateIsFatal(bool cannotRecover);
143
144 void setOcspStaplingEnabled(bool enable);
145 bool ocspStaplingEnabled() const;
146
147 enum NextProtocolNegotiationStatus {
148 NextProtocolNegotiationNone,
149 NextProtocolNegotiationNegotiated,
150 NextProtocolNegotiationUnsupported
151 };
152
153 void setAllowedNextProtocols(const QList<QByteArray> &protocols);
154 QList<QByteArray> allowedNextProtocols() const;
155
156 QByteArray nextNegotiatedProtocol() const;
157 NextProtocolNegotiationStatus nextProtocolNegotiationStatus() const;
158
159 static const char ALPNProtocolHTTP2[];
160 static const char NextProtocolHttp1_1[];
161
162 QList<QSslKeyingMaterial> keyingMaterial() const;
163 std::optional<QSslKeyingMaterial> keyingMaterial(const QSslKeyingMaterial &material) const;
164 void setKeyingMaterial(const QList<QSslKeyingMaterial> &keyMaterial);
165
166private:
167 friend class QSslSocket;
168 friend class QSslConfigurationPrivate;
169 friend class QSslContext;
170 friend class QTlsBackend;
171 QSslConfiguration(QSslConfigurationPrivate *dd);
172 QSharedDataPointer<QSslConfigurationPrivate> d;
173};
174
176
177QT_END_NAMESPACE
178
179QT_DECL_METATYPE_EXTERN(QSslConfiguration, Q_NETWORK_EXPORT)
180
181#endif // QT_NO_SSL
182
183#endif
QByteArray rawHeader(QAnyStringView headerName) const
void setCookedHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)
QList< QByteArray > rawHeadersKeys() const
QHttpHeaders headers() const
void setHeaders(QHttpHeaders &&newHeaders)
void setHeaders(const QHttpHeaders &newHeaders)
const RawHeadersList & allRawHeaders() const
void setHeader(QHttpHeaders::WellKnownHeader name, QByteArrayView value)
QList< RawHeaderPair > RawHeadersList
CookedHeadersMap cookedHeaders
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
The QSslConfiguration class holds the configuration and state of an SSL connection.
Represents an elliptic curve for use by elliptic-curve cipher algorithms.
Describes exported keying material derived from a TLS session.
Combined button and popup list for selecting options.
static int name_to_month(const char *month_str)
static QStringList parseMatchImpl(QByteArrayView raw, T op)
static bool isSetCookie(QByteArrayView name)
static QList< QNetworkCookie > parseCookieHeader(QByteArrayView raw)
static int parseHeaderName(QByteArrayView headerName)
static std::optional< QNetworkRequest::KnownHeaders > toKnownHeader(QHttpHeaders::WellKnownHeader key)
static QVariant parseETag(QByteArrayView raw)
static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, QByteArrayView value)
static QVariant parseHttpDate(QByteArrayView raw)
static QByteArray headerValue(QNetworkRequest::KnownHeaders header, const QVariant &value)
static QByteArray makeCookieHeader(const QList< QNetworkCookie > &cookies, QNetworkCookie::RawForm type, QByteArrayView separator)
static QStringList parseIfMatch(QByteArrayView raw)
static QStringList parseIfNoneMatch(QByteArrayView raw)
static void setFromRawHeader(QHttpHeaders &headers, HeaderName header, QByteArrayView value)
static std::optional< QHttpHeaders::WellKnownHeader > toWellKnownHeader(QNetworkRequest::KnownHeaders key)
static constexpr HeaderPair knownHeadersArr[]