Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
5/****************************************************************************
6**
7** In addition, as a special exception, the copyright holders listed above give
8** permission to link the code of its release of Qt with the OpenSSL project's
9** "OpenSSL" library (or modified versions of the "OpenSSL" library that use the
10** same license as the original version), and distribute the linked executables.
11**
12** You must comply with the GNU General Public License version 2 in all
13** respects for all of the code used other than the "OpenSSL" code. If you
14** modify this file, you may extend this exception to your version of the file,
15** but you are not obligated to do so. If you do not wish to do so, delete
16** this exception statement from your version of this file.
17**
18****************************************************************************/
19
20#ifndef QSSLCONFIGURATION_H
21#define QSSLCONFIGURATION_H
22
23#include <QtNetwork/qtnetworkglobal.h>
24#include <QtCore/qmap.h>
25#include <QtCore/qshareddata.h>
26#include <QtNetwork/qsslsocket.h>
27#include <QtNetwork/qssl.h>
28
29#ifndef QT_NO_SSL
30
32
33class QSslCertificate;
34class QSslCipher;
35class QSslKey;
38
40class Q_NETWORK_EXPORT QSslConfiguration
41{
42public:
47 QSslConfiguration &operator=(const QSslConfiguration &other);
48
50 { d.swap(other.d); }
51
52 bool operator==(const QSslConfiguration &other) const;
53 inline bool operator!=(const QSslConfiguration &other) const
54 { return !(*this == other); }
55
56 bool isNull() const;
57
58 QSsl::SslProtocol protocol() const;
59 void setProtocol(QSsl::SslProtocol protocol);
60
61 // Verification
62 QSslSocket::PeerVerifyMode peerVerifyMode() const;
63 void setPeerVerifyMode(QSslSocket::PeerVerifyMode mode);
64
65 int peerVerifyDepth() const;
66 void setPeerVerifyDepth(int depth);
67
68 // Certificate & cipher configuration
69 QList<QSslCertificate> localCertificateChain() const;
70 void setLocalCertificateChain(const QList<QSslCertificate> &localChain);
71
72 QSslCertificate localCertificate() const;
73 void setLocalCertificate(const QSslCertificate &certificate);
74
75 QSslCertificate peerCertificate() const;
76 QList<QSslCertificate> peerCertificateChain() const;
77 QSslCipher sessionCipher() const;
78 QSsl::SslProtocol sessionProtocol() const;
79
80 // Private keys, for server sockets
81 QSslKey privateKey() const;
82 void setPrivateKey(const QSslKey &key);
83
84 // Cipher settings
85 QList<QSslCipher> ciphers() const;
86 void setCiphers(const QList<QSslCipher> &ciphers);
87 void setCiphers(const QString &ciphers);
88 static QList<QSslCipher> supportedCiphers();
89
90 // Certificate Authority (CA) settings
91 QList<QSslCertificate> caCertificates() const;
92 void setCaCertificates(const QList<QSslCertificate> &certificates);
93 bool addCaCertificates(
96 void addCaCertificate(const QSslCertificate &certificate);
97 void addCaCertificates(const QList<QSslCertificate> &certificates);
98
99 static QList<QSslCertificate> systemCaCertificates();
100
101 void setSslOption(QSsl::SslOption option, bool on);
102 bool testSslOption(QSsl::SslOption option) const;
103
104 QByteArray sessionTicket() const;
105 void setSessionTicket(const QByteArray &sessionTicket);
106 int sessionTicketLifeTimeHint() const;
107
108 QSslKey ephemeralServerKey() const;
109
110 // EC settings
111 QList<QSslEllipticCurve> ellipticCurves() const;
112 void setEllipticCurves(const QList<QSslEllipticCurve> &curves);
113 static QList<QSslEllipticCurve> supportedEllipticCurves();
114
115 QByteArray preSharedKeyIdentityHint() const;
116 void setPreSharedKeyIdentityHint(const QByteArray &hint);
117
118 QSslDiffieHellmanParameters diffieHellmanParameters() const;
119 void setDiffieHellmanParameters(const QSslDiffieHellmanParameters &dhparams);
120
121 QMap<QByteArray, QVariant> backendConfiguration() const;
122 void setBackendConfigurationOption(const QByteArray &name, const QVariant &value);
123 void setBackendConfiguration(const QMap<QByteArray, QVariant> &backendConfiguration = QMap<QByteArray, QVariant>());
124
125 static QSslConfiguration defaultConfiguration();
126 static void setDefaultConfiguration(const QSslConfiguration &configuration);
127
128#if QT_CONFIG(dtls) || defined(Q_QDOC)
129 bool dtlsCookieVerificationEnabled() const;
131
132 static QSslConfiguration defaultDtlsConfiguration();
133 static void setDefaultDtlsConfiguration(const QSslConfiguration &configuration);
134#endif // dtls
135
136 bool handshakeMustInterruptOnError() const;
137 void setHandshakeMustInterruptOnError(bool interrupt);
138
139 bool missingCertificateIsFatal() const;
140 void setMissingCertificateIsFatal(bool cannotRecover);
141
142 void setOcspStaplingEnabled(bool enable);
143 bool ocspStaplingEnabled() const;
144
150
151 void setAllowedNextProtocols(const QList<QByteArray> &protocols);
152 QList<QByteArray> allowedNextProtocols() const;
153
154 QByteArray nextNegotiatedProtocol() const;
155 NextProtocolNegotiationStatus nextProtocolNegotiationStatus() const;
156
157 static const char ALPNProtocolHTTP2[];
158 static const char NextProtocolHttp1_1[];
159
160private:
161 friend class QSslSocket;
163 friend class QSslContext;
164 friend class QTlsBackend;
166 QSharedDataPointer<QSslConfigurationPrivate> d;
167};
168
169Q_DECLARE_SHARED(QSslConfiguration)
170
172
174
175#endif // QT_NO_SSL
176
177#endif
\inmodule QtCore
Definition qbytearray.h:57
The QSslCertificate class provides a convenient API for an X509 certificate.
The QSslCipher class represents an SSL cryptographic cipher.
Definition qsslcipher.h:22
The QSslConfiguration class holds the configuration and state of an SSL connection.
QSslConfiguration & operator=(QSslConfiguration &&other) noexcept
void swap(QSslConfiguration &other) noexcept
bool operator!=(const QSslConfiguration &other) const
Returns true if this QSslConfiguration differs from other.
NextProtocolNegotiationStatus
Describes the status of the Next Protocol Negotiation (NPN) or Application-Layer Protocol Negotiation...
The QSslDiffieHellmanParameters class provides an interface for Diffie-Hellman parameters for servers...
Represents an elliptic curve for use by elliptic-curve cipher algorithms.
The QSslKey class provides an interface for private and public keys.
Definition qsslkey.h:23
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition qsslsocket.h:29
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QTlsBackend is a factory class, providing implementations for the QSsl classes.
\inmodule QtCore
Definition qvariant.h:65
EncodingFormat
Describes supported encoding formats for certificates and keys.
Definition qssl.h:28
@ Pem
Definition qssl.h:29
SslOption
Describes the options that can be used to control the details of SSL behaviour.
Definition qssl.h:73
SslProtocol
Describes the protocol of the cipher.
Definition qssl.h:50
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition qmetatype.h:1388
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum mode
GLuint64 key
GLboolean enable
GLuint name
GLint GLsizei GLsizei GLenum format
GLsizei const GLchar *const * path
GLuint GLenum option
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
QSharedPointer< T > other(t)
[5]
this swap(other)
config setDtlsCookieVerificationEnabled(false)
config setProtocol(QSsl::TlsV1_2)