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_P_H |
21 | #define QSSLCONFIGURATION_P_H |
22 | |
23 | // |
24 | // W A R N I N G |
25 | // ------------- |
26 | // |
27 | // This file is not part of the Qt API. It exists for the convenience |
28 | // of the QSslSocket API. This header file may change from |
29 | // version to version without notice, or even be removed. |
30 | // |
31 | // We mean it. |
32 | // |
33 | |
34 | #include <QtCore/qmap.h> |
35 | #include <QtNetwork/private/qtnetworkglobal_p.h> |
36 | #include "qsslconfiguration.h" |
37 | #include "qlist.h" |
38 | #include "qsslcertificate.h" |
39 | #include "qsslcipher.h" |
40 | #include "qsslkey.h" |
41 | #include "qsslellipticcurve.h" |
42 | #include "qssldiffiehellmanparameters.h" |
43 | |
44 | QT_BEGIN_NAMESPACE |
45 | |
46 | class QSslConfigurationPrivate: public QSharedData |
47 | { |
48 | public: |
49 | QSslConfigurationPrivate() |
50 | : sessionProtocol(QSsl::UnknownProtocol), |
51 | protocol(QSsl::SecureProtocols), |
52 | peerVerifyMode(QSslSocket::AutoVerifyPeer), |
53 | peerVerifyDepth(0), |
54 | allowRootCertOnDemandLoading(true), |
55 | peerSessionShared(false), |
56 | sslOptions(QSslConfigurationPrivate::defaultSslOptions), |
57 | dhParams(QSslDiffieHellmanParameters::defaultParameters()), |
58 | sslSessionTicketLifeTimeHint(-1), |
59 | ephemeralServerKey(), |
60 | preSharedKeyIdentityHint(), |
61 | nextProtocolNegotiationStatus(QSslConfiguration::NextProtocolNegotiationNone) |
62 | { } |
63 | |
64 | QSslCertificate peerCertificate; |
65 | QList<QSslCertificate> peerCertificateChain; |
66 | |
67 | QList<QSslCertificate> localCertificateChain; |
68 | |
69 | QSslKey privateKey; |
70 | QSslCipher sessionCipher; |
71 | QSsl::SslProtocol sessionProtocol; |
72 | QList<QSslCipher> ciphers; |
73 | QList<QSslCertificate> caCertificates; |
74 | |
75 | QSsl::SslProtocol protocol; |
76 | QSslSocket::PeerVerifyMode peerVerifyMode; |
77 | int peerVerifyDepth; |
78 | bool allowRootCertOnDemandLoading; |
79 | bool peerSessionShared; |
80 | |
81 | Q_AUTOTEST_EXPORT static bool peerSessionWasShared(const QSslConfiguration &configuration); |
82 | |
83 | QSsl::SslOptions sslOptions; |
84 | |
85 | static const QSsl::SslOptions defaultSslOptions; |
86 | |
87 | QList<QSslEllipticCurve> ellipticCurves; |
88 | |
89 | QSslDiffieHellmanParameters dhParams; |
90 | |
91 | QMap<QByteArray, QVariant> backendConfig; |
92 | |
93 | QByteArray sslSession; |
94 | int sslSessionTicketLifeTimeHint; |
95 | |
96 | QSslKey ephemeralServerKey; |
97 | |
98 | QByteArray preSharedKeyIdentityHint; |
99 | |
100 | QList<QByteArray> nextAllowedProtocols; |
101 | QByteArray nextNegotiatedProtocol; |
102 | QSslConfiguration::NextProtocolNegotiationStatus nextProtocolNegotiationStatus; |
103 | |
104 | #if QT_CONFIG(dtls) |
105 | bool dtlsCookieEnabled = true; |
106 | #else |
107 | const bool dtlsCookieEnabled = false; |
108 | #endif // dtls |
109 | |
110 | #if QT_CONFIG(ocsp) |
111 | bool ocspStaplingEnabled = false; |
112 | #else |
113 | const bool ocspStaplingEnabled = false; |
114 | #endif |
115 | |
116 | #if QT_CONFIG(openssl) |
117 | bool reportFromCallback = false; |
118 | bool missingCertIsFatal = false; |
119 | #else |
120 | const bool reportFromCallback = false; |
121 | const bool missingCertIsFatal = false; |
122 | #endif // openssl |
123 | |
124 | // in qsslsocket.cpp: |
125 | static QSslConfiguration defaultConfiguration(); |
126 | static void setDefaultConfiguration(const QSslConfiguration &configuration); |
127 | static void deepCopyDefaultConfiguration(QSslConfigurationPrivate *config); |
128 | |
129 | static QSslConfiguration defaultDtlsConfiguration(); |
130 | static void setDefaultDtlsConfiguration(const QSslConfiguration &configuration); |
131 | }; |
132 | |
133 | // implemented here for inlining purposes |
134 | inline QSslConfiguration::QSslConfiguration(QSslConfigurationPrivate *dd) |
135 | : d(dd) |
136 | { |
137 | } |
138 | |
139 | QT_END_NAMESPACE |
140 | |
141 | #endif |
142 | |