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
qssl.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 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// Qt-Security score:significant reason:default
4
5
6#include "qsslkey.h"
7#include "qssl_p.h"
8
10
11Q_LOGGING_CATEGORY(lcSsl, "qt.network.ssl");
12
13/*! \namespace QSsl
14
15 \brief The QSsl namespace declares enums common to all SSL classes in Qt Network.
16 \since 4.3
17
18 \ingroup network
19 \ingroup ssl
20 \inmodule QtNetwork
21*/
22
23/*!
24 \enum QSsl::KeyType
25
26 Describes the two types of keys QSslKey supports.
27
28 \value PrivateKey A private key.
29 \value PublicKey A public key.
30*/
31
32/*!
33 \enum QSsl::KeyAlgorithm
34
35 Describes the different key algorithms supported by QSslKey.
36
37 \value MlDsa The ML-DSA algorithm.
38 \value Rsa The RSA algorithm.
39 \value Dsa The DSA algorithm.
40 \value Ec The Elliptic Curve algorithm.
41 \value Dh The Diffie-Hellman algorithm.
42 \value Opaque A key that should be treated as a 'black box' by QSslKey.
43
44 The opaque key facility allows applications to add support for facilities
45 such as PKCS#11 that Qt does not currently offer natively.
46*/
47
48/*!
49 \enum QSsl::EncodingFormat
50
51 Describes supported encoding formats for certificates and keys.
52
53 \value Pem The PEM format.
54 \value Der The DER format.
55*/
56
57/*!
58 \enum QSsl::AlternativeNameEntryType
59
60 Describes the key types for alternative name entries in QSslCertificate.
61
62 \value EmailEntry An email entry; the entry contains an email address that
63 the certificate is valid for.
64
65 \value DnsEntry A DNS host name entry; the entry contains a host name
66 entry that the certificate is valid for. The entry may contain wildcards.
67
68 \value IpAddressEntry An IP address entry; the entry contains an IP address
69 entry that the certificate is valid for, introduced in Qt 5.13.
70
71 \sa QSslCertificate::subjectAlternativeNames()
72*/
73
74/*!
75 \enum QSsl::SslProtocol
76
77 Describes the protocol of the cipher.
78
79 \value TlsV1_0 TLSv1.0
80 \value TlsV1_0OrLater TLSv1.0 and later versions.
81 \value TlsV1_1 TLSv1.1.
82 \value TlsV1_1OrLater TLSv1.1 and later versions.
83 \value TlsV1_2 TLSv1.2.
84 \value TlsV1_2OrLater TLSv1.2 and later versions.
85 \value DtlsV1_0 DTLSv1.0
86 \value DtlsV1_0OrLater DTLSv1.0 and later versions.
87 \value DtlsV1_2 DTLSv1.2
88 \value DtlsV1_2OrLater DTLSv1.2 and later versions.
89 \value [since 5.12] TlsV1_3 TLSv1.3.
90 \value [since 5.12] TlsV1_3OrLater TLSv1.3 and later versions.
91 \value UnknownProtocol The cipher's protocol cannot be determined.
92 \value AnyProtocol Any supported protocol. This value is used by QSslSocket only.
93 \value SecureProtocols The default option, using protocols known to be secure.
94*/
95
96/*!
97 \enum QSsl::SslOption
98
99 Describes the options that can be used to control the details of
100 SSL behaviour. These options are generally used to turn features off
101 to work around buggy servers.
102
103 \value SslOptionDisableEmptyFragments Disables the insertion of empty
104 fragments into the data when using block ciphers. When enabled, this
105 prevents some attacks (such as the BEAST attack), however it is
106 incompatible with some servers.
107 \value SslOptionDisableSessionTickets Disables the SSL session ticket
108 extension. This can cause slower connection setup, however some servers
109 are not compatible with the extension.
110 \value SslOptionDisableCompression Disables the SSL compression
111 extension. When enabled, this allows the data being passed over SSL to
112 be compressed, however some servers are not compatible with this
113 extension.
114 \value SslOptionDisableServerNameIndication Disables the SSL server
115 name indication extension. When enabled, this tells the server the virtual
116 host being accessed allowing it to respond with the correct certificate.
117 \value SslOptionDisableLegacyRenegotiation Disables the older insecure
118 mechanism for renegotiating the connection parameters. When enabled, this
119 option can allow connections for legacy servers, but it introduces the
120 possibility that an attacker could inject plaintext into the SSL session.
121 \value SslOptionDisableSessionSharing Disables SSL session sharing via
122 the session ID handshake attribute.
123 \value SslOptionDisableSessionPersistence Disables storing the SSL session
124 in ASN.1 format as returned by QSslConfiguration::sessionTicket(). Enabling
125 this feature adds memory overhead of approximately 1K per used session
126 ticket.
127 \value SslOptionDisableServerCipherPreference Disables selecting the cipher
128 chosen based on the servers preferences rather than the order ciphers were
129 sent by the client. This option is only relevant to server sockets, and is
130 only honored by the OpenSSL backend.
131
132 By default, SslOptionDisableEmptyFragments is turned on since this causes
133 problems with a large number of servers. SslOptionDisableLegacyRenegotiation
134 is also turned on, since it introduces a security risk.
135 SslOptionDisableCompression is turned on to prevent the attack publicised by
136 CRIME.
137 SslOptionDisableSessionPersistence is turned on to optimize memory usage.
138 The other options are turned off.
139
140 \note Availability of above options depends on the version of the SSL
141 backend in use.
142*/
143
144/*!
145 \enum QSsl::AlertLevel
146 \brief Describes the level of an alert message
147 \relates QSslSocket
148 \since 6.0
149
150 \ingroup network
151 \ingroup ssl
152 \inmodule QtNetwork
153
154 This enum describes the level of an alert message that was sent
155 or received.
156
157 \value Warning Non-fatal alert message
158 \value Fatal Fatal alert message, the underlying backend will
159 handle such an alert properly and close the connection.
160 \value Unknown An alert of unknown level of severity.
161*/
162
163/*!
164 \enum QSsl::AlertType
165 \brief Enumerates possible codes that an alert message can have
166 \relates QSslSocket
167 \since 6.0
168
169 \ingroup network
170 \ingroup ssl
171 \inmodule QtNetwork
172
173 See \l{RFC 8446, section 6}
174 for the possible values and their meaning.
175
176 \value CloseNotify,
177 \value UnexpectedMessage
178 \value BadRecordMac
179 \value RecordOverflow
180 \value DecompressionFailure
181 \value HandshakeFailure
182 \value NoCertificate
183 \value BadCertificate
184 \value UnsupportedCertificate
185 \value CertificateRevoked
186 \value CertificateExpired
187 \value CertificateUnknown
188 \value IllegalParameter
189 \value UnknownCa
190 \value AccessDenied
191 \value DecodeError
192 \value DecryptError
193 \value ExportRestriction
194 \value ProtocolVersion
195 \value InsufficientSecurity
196 \value InternalError
197 \value InappropriateFallback
198 \value UserCancelled
199 \value NoRenegotiation
200 \value MissingExtension
201 \value UnsupportedExtension
202 \value CertificateUnobtainable
203 \value UnrecognizedName
204 \value BadCertificateStatusResponse
205 \value BadCertificateHashValue
206 \value UnknownPskIdentity
207 \value CertificateRequired
208 \value NoApplicationProtocol
209 \value UnknownAlertMessage
210*/
211
212/*!
213 \enum QSsl::ImplementedClass
214 \brief Enumerates classes that a TLS backend implements
215 \relates QSslSocket
216 \since 6.1
217
218 \ingroup network
219 \ingroup ssl
220 \inmodule QtNetwork
221
222 In QtNetwork, some classes have backend-specific implementation and thus
223 can be left unimplemented. Enumerators in this enum indicate, which class
224 has a working implementation in the backend.
225
226 \value Key Class QSslKey.
227 \value Certificate Class QSslCertificate.
228 \value Socket Class QSslSocket.
229 \value DiffieHellman Class QSslDiffieHellmanParameters.
230 \value EllipticCurve Class QSslEllipticCurve.
231 \value Dtls Class QDtls.
232 \value DtlsCookie Class QDtlsClientVerifier.
233*/
234
235/*!
236 \enum QSsl::SupportedFeature
237 \brief Enumerates possible features that a TLS backend supports
238 \relates QSslSocket
239 \since 6.1
240
241 \ingroup network
242 \ingroup ssl
243 \inmodule QtNetwork
244
245 In QtNetwork TLS-related classes have public API, that may be left unimplemented
246 by some backend, for example, our SecureTransport backend does not support
247 server-side ALPN. Enumerators from SupportedFeature enum indicate that a particular
248 feature is supported.
249
250 \value CertificateVerification Indicates that QSslCertificate::verify() is
251 implemented by the backend.
252 \value ClientSideAlpn Client-side ALPN (Application Layer Protocol Negotiation).
253 \value ServerSideAlpn Server-side ALPN.
254 \value Ocsp OCSP stapling (Online Certificate Status Protocol).
255 \value Psk Pre-shared keys.
256 \value SessionTicket Session tickets.
257 \value Alerts Information about alert messages sent and received.
258*/
259
260QT_END_NAMESPACE
261
262#include "moc_qssl.cpp"