qsslcontext_openssl.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qsslcontext_openssl.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2014 BlackBerry Limited. All rights reserved.-
5** Copyright (C) 2014 Governikus GmbH & Co. KG.-
6** Contact: https://www.qt.io/licensing/-
7**-
8** This file is part of the QtNetwork module of the Qt Toolkit.-
9**-
10** $QT_BEGIN_LICENSE:LGPL$-
11** Commercial License Usage-
12** Licensees holding valid commercial Qt licenses may use this file in-
13** accordance with the commercial license agreement provided with the-
14** Software or, alternatively, in accordance with the terms contained in-
15** a written agreement between you and The Qt Company. For licensing terms-
16** and conditions see https://www.qt.io/terms-conditions. For further-
17** information use the contact form at https://www.qt.io/contact-us.-
18**-
19** GNU Lesser General Public License Usage-
20** Alternatively, this file may be used under the terms of the GNU Lesser-
21** General Public License version 3 as published by the Free Software-
22** Foundation and appearing in the file LICENSE.LGPL3 included in the-
23** packaging of this file. Please review the following information to-
24** ensure the GNU Lesser General Public License version 3 requirements-
25** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
26**-
27** GNU General Public License Usage-
28** Alternatively, this file may be used under the terms of the GNU-
29** General Public License version 2.0 or (at your option) the GNU General-
30** Public license version 3 or any later version approved by the KDE Free-
31** Qt Foundation. The licenses are as published by the Free Software-
32** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
33** included in the packaging of this file. Please review the following-
34** information to ensure the GNU General Public License requirements will-
35** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
36** https://www.gnu.org/licenses/gpl-3.0.html.-
37**-
38** $QT_END_LICENSE$-
39**-
40****************************************************************************/-
41-
42-
43#include <QtNetwork/qsslsocket.h>-
44#include <QtCore/qmutex.h>-
45-
46#include "private/qssl_p.h"-
47#include "private/qsslcontext_openssl_p.h"-
48#include "private/qsslsocket_p.h"-
49#include "private/qsslsocket_openssl_p.h"-
50#include "private/qsslsocket_openssl_symbols_p.h"-
51-
52QT_BEGIN_NAMESPACE-
53-
54// defined in qsslsocket_openssl.cpp:-
55extern int q_X509Callback(int ok, X509_STORE_CTX *ctx);-
56extern QString getErrorsFromOpenSsl();-
57-
58static DH *get_dh1024()-
59{-
60 // Default DH params-
61 // 1024-bit MODP Group-
62 // From RFC 2409-
63 QByteArray params = QByteArray::fromBase64(-
64 QByteArrayLiteral("MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR" \
executed 450 times by 7 tests: return ba;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
450
65 "Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL" \-
66 "/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC"));-
67-
68 const char *ptr = params.constData();-
69 DH *dh = q_d2i_DHparams(NULL, reinterpret_cast<const unsigned char **>(&ptr), params.length());-
70-
71 return dh;
executed 450 times by 7 tests: return dh;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
450
72}-
73-
74QSslContext::QSslContext()-
75 : ctx(0),-
76 pkey(0),-
77 session(0),-
78 m_sessionTicketLifeTimeHint(-1)-
79{-
80}
executed 458 times by 7 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
458
81-
82QSslContext::~QSslContext()-
83{-
84 if (ctx)
ctxDescription
TRUEevaluated 457 times by 8 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_spdy - unknown status
FALSEnever evaluated
0-457
85 // This will decrement the reference count by 1 and free the context eventually when possible-
86 q_SSL_CTX_free(ctx);
executed 457 times by 8 tests: q_SSL_CTX_free(ctx);
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_spdy - unknown status
457
87-
88 if (pkey)
pkeyDescription
TRUEevaluated 83 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 374 times by 8 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_spdy - unknown status
83-374
89 q_EVP_PKEY_free(pkey);
executed 83 times by 2 tests: q_EVP_PKEY_free(pkey);
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
83
90-
91 if (session)
sessionDescription
TRUEevaluated 333 times by 8 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_spdy - unknown status
FALSEevaluated 124 times by 6 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
124-333
92 q_SSL_SESSION_free(session);
executed 333 times by 8 tests: q_SSL_SESSION_free(session);
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_spdy - unknown status
333
93}
executed 457 times by 8 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_spdy - unknown status
457
94-
95static inline QString msgErrorSettingEllipticCurves(const QString &why)-
96{-
97 return QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(why);
never executed: return QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(why);
0
98}-
99-
100// static-
101void QSslContext::initSslContext(QSslContext *sslContext, QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading)-
102{-
103 sslContext->sslConfiguration = configuration;-
104 sslContext->errorCode = QSslError::NoError;-
105-
106 bool client = (mode == QSslSocket::SslClientMode);-
107-
108 bool reinitialized = false;-
109 bool unsupportedProtocol = false;-
110init_context:
code before this statement executed 458 times by 7 tests: init_context:
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
458
111 switch (sslContext->sslConfiguration.protocol()) {-
112 case QSsl::SslV2:
never executed: case QSsl::SslV2:
0
113#ifndef OPENSSL_NO_SSL2-
114 sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv2_client_method() : q_SSLv2_server_method());-
115#else-
116 // SSL 2 not supported by the system, but chosen deliberately -> error-
117 sslContext->ctx = 0;-
118 unsupportedProtocol = true;-
119#endif-
120 break;
never executed: break;
0
121 case QSsl::SslV3:
executed 19 times by 1 test: case QSsl::SslV3:
Executed by:
  • tst_qsslsocket - unknown status
19
122#ifndef OPENSSL_NO_SSL3_METHOD-
123 sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv3_client_method() : q_SSLv3_server_method());-
124#else-
125 // SSL 3 not supported by the system, but chosen deliberately -> error-
126 sslContext->ctx = 0;-
127 unsupportedProtocol = true;-
128#endif-
129 break;
executed 19 times by 1 test: break;
Executed by:
  • tst_qsslsocket - unknown status
19
130 case QSsl::SecureProtocols:
executed 328 times by 7 tests: case QSsl::SecureProtocols:
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
328
131 // SSLv2 and SSLv3 will be disabled by SSL options-
132 // But we need q_SSLv23_server_method() otherwise AnyProtocol will be unable to connect on Win32.-
133 case QSsl::TlsV1SslV3:
executed 18 times by 1 test: case QSsl::TlsV1SslV3:
Executed by:
  • tst_qsslsocket - unknown status
18
134 // SSLv2 will will be disabled by SSL options-
135 case QSsl::AnyProtocol:
executed 24 times by 2 tests: case QSsl::AnyProtocol:
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
24
136 default:
never executed: default:
0
137 sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());-
138 break;
executed 370 times by 7 tests: break;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
370
139 case QSsl::TlsV1_0:
executed 51 times by 1 test: case QSsl::TlsV1_0:
Executed by:
  • tst_qsslsocket - unknown status
51
140 sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_client_method() : q_TLSv1_server_method());-
141 break;
executed 51 times by 1 test: break;
Executed by:
  • tst_qsslsocket - unknown status
51
142 case QSsl::TlsV1_1:
executed 9 times by 1 test: case QSsl::TlsV1_1:
Executed by:
  • tst_qsslsocket - unknown status
9
143#if OPENSSL_VERSION_NUMBER >= 0x10001000L-
144 sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_1_client_method() : q_TLSv1_1_server_method());-
145#else-
146 // TLS 1.1 not supported by the system, but chosen deliberately -> error-
147 sslContext->ctx = 0;-
148 unsupportedProtocol = true;-
149#endif-
150 break;
executed 9 times by 1 test: break;
Executed by:
  • tst_qsslsocket - unknown status
9
151 case QSsl::TlsV1_2:
executed 9 times by 1 test: case QSsl::TlsV1_2:
Executed by:
  • tst_qsslsocket - unknown status
9
152#if OPENSSL_VERSION_NUMBER >= 0x10001000L-
153 sslContext->ctx = q_SSL_CTX_new(client ? q_TLSv1_2_client_method() : q_TLSv1_2_server_method());-
154#else-
155 // TLS 1.2 not supported by the system, but chosen deliberately -> error-
156 sslContext->ctx = 0;-
157 unsupportedProtocol = true;-
158#endif-
159 break;
executed 9 times by 1 test: break;
Executed by:
  • tst_qsslsocket - unknown status
9
160 case QSsl::TlsV1_0OrLater:
never executed: case QSsl::TlsV1_0OrLater:
0
161 // Specific protocols will be specified via SSL options.-
162 sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());-
163 break;
never executed: break;
0
164 case QSsl::TlsV1_1OrLater:
never executed: case QSsl::TlsV1_1OrLater:
0
165 case QSsl::TlsV1_2OrLater:
never executed: case QSsl::TlsV1_2OrLater:
0
166#if OPENSSL_VERSION_NUMBER >= 0x10001000L-
167 // Specific protocols will be specified via SSL options.-
168 sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());-
169#else-
170 // TLS 1.1/1.2 not supported by the system, but chosen deliberately -> error-
171 sslContext->ctx = 0;-
172 unsupportedProtocol = true;-
173#endif-
174 break;
never executed: break;
0
175 }-
176-
177 if (!sslContext->ctx) {
!sslContext->ctxDescription
TRUEnever evaluated
FALSEevaluated 458 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
0-458
178 // After stopping Flash 10 the SSL library looses its ciphers. Try re-adding them-
179 // by re-initializing the library.-
180 if (!reinitialized) {
!reinitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
181 reinitialized = true;-
182 if (q_SSL_library_init() == 1)
q_SSL_library_init() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
183 goto init_context;
never executed: goto init_context;
0
184 }
never executed: end of block
0
185-
186 sslContext->errorStr = QSslSocket::tr("Error creating SSL context (%1)").arg(-
187 unsupportedProtocol ? QSslSocket::tr("unsupported protocol") : QSslSocketBackendPrivate::getErrorsFromOpenSsl()-
188 );-
189 sslContext->errorCode = QSslError::UnspecifiedError;-
190 return;
never executed: return;
0
191 }-
192-
193 // Enable bug workarounds.-
194 long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);-
195 q_SSL_CTX_set_options(sslContext->ctx, options);-
196-
197#if OPENSSL_VERSION_NUMBER >= 0x10000000L-
198 // Tell OpenSSL to release memory early-
199 // http://www.openssl.org/docs/ssl/SSL_CTX_set_mode.html-
200 if (q_SSLeay() >= 0x10000000L)
q_SSLeay() >= 0x10000000LDescription
TRUEevaluated 458 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEnever evaluated
0-458
201 q_SSL_CTX_set_mode(sslContext->ctx, SSL_MODE_RELEASE_BUFFERS);
executed 458 times by 7 tests: q_SSL_CTX_ctrl((sslContext->ctx),33,(0x00000010L),__null);
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
458
202#endif-
203-
204 // Initialize ciphers-
205 QByteArray cipherString;-
206 bool first = true;-
207 QList<QSslCipher> ciphers = sslContext->sslConfiguration.ciphers();-
208 if (ciphers.isEmpty())
ciphers.isEmpty()Description
TRUEevaluated 54 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 404 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
54-404
209 ciphers = QSslSocketPrivate::defaultCiphers();
executed 54 times by 4 tests: ciphers = QSslSocketPrivate::defaultCiphers();
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
54
210 for (const QSslCipher &cipher : qAsConst(ciphers)) {-
211 if (first)
firstDescription
TRUEevaluated 451 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 28800 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
451-28800
212 first = false;
executed 451 times by 7 tests: first = false;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
451
213 else-
214 cipherString.append(':');
executed 28800 times by 7 tests: cipherString.append(':');
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
28800
215 cipherString.append(cipher.name().toLatin1());-
216 }
executed 29251 times by 7 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
29251
217-
218 if (!q_SSL_CTX_set_cipher_list(sslContext->ctx, cipherString.data())) {
!q_SSL_CTX_set...String.data())Description
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 451 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
7-451
219 sslContext->errorStr = QSslSocket::tr("Invalid or empty cipher list (%1)").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());-
220 sslContext->errorCode = QSslError::UnspecifiedError;-
221 return;
executed 7 times by 2 tests: return;
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
7
222 }-
223-
224 const QDateTime now = QDateTime::currentDateTimeUtc();-
225-
226 // Add all our CAs to this store.-
227 const auto caCertificates = sslContext->sslConfiguration.caCertificates();-
228 for (const QSslCertificate &caCertificate : caCertificates) {-
229 // From https://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html:-
230 //-
231 // If several CA certificates matching the name, key identifier, and-
232 // serial number condition are available, only the first one will be-
233 // examined. This may lead to unexpected results if the same CA-
234 // certificate is available with different expiration dates. If a-
235 // ``certificate expired'' verification error occurs, no other-
236 // certificate will be searched. Make sure to not have expired-
237 // certificates mixed with valid ones.-
238 //-
239 // See also: QSslSocketBackendPrivate::verify()-
240 if (caCertificate.expiryDate() >= now) {
caCertificate....yDate() >= nowDescription
TRUEevaluated 51484 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 3454 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
3454-51484
241 q_X509_STORE_add_cert(q_SSL_CTX_get_cert_store(sslContext->ctx), (X509 *)caCertificate.handle());-
242 }
executed 51484 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
51484
243 }
executed 54938 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
54938
244-
245 if (QSslSocketPrivate::s_loadRootCertsOnDemand && allowRootCertOnDemandLoading) {
QSslSocketPriv...tCertsOnDemandDescription
TRUEevaluated 111 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket_onDemandCertificates_member - unknown status
FALSEevaluated 340 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
allowRootCertOnDemandLoadingDescription
TRUEevaluated 63 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket_onDemandCertificates_member - unknown status
FALSEevaluated 48 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket_onDemandCertificates_member - unknown status
48-340
246 // tell OpenSSL the directories where to look up the root certs on demand-
247 const QList<QByteArray> unixDirs = QSslSocketPrivate::unixRootCertDirectories();-
248 for (const QByteArray &unixDir : unixDirs)-
249 q_SSL_CTX_load_verify_locations(sslContext->ctx, 0, unixDir.constData());
executed 567 times by 5 tests: q_SSL_CTX_load_verify_locations(sslContext->ctx, 0, unixDir.constData());
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket_onDemandCertificates_member - unknown status
567
250 }
executed 63 times by 5 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket_onDemandCertificates_member - unknown status
63
251-
252 if (!sslContext->sslConfiguration.localCertificate().isNull()) {
!sslContext->s...ate().isNull()Description
TRUEevaluated 89 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 362 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
89-362
253 // Require a private key as well.-
254 if (sslContext->sslConfiguration.privateKey().isNull()) {
sslContext->ss...Key().isNull()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
1-88
255 sslContext->errorStr = QSslSocket::tr("Cannot provide a certificate with no key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());-
256 sslContext->errorCode = QSslError::UnspecifiedError;-
257 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_qsslsocket - unknown status
1
258 }-
259-
260 // Load certificate-
261 if (!q_SSL_CTX_use_certificate(sslContext->ctx, (X509 *)sslContext->sslConfiguration.localCertificate().handle())) {
!q_SSL_CTX_use...te().handle())Description
TRUEnever evaluated
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
0-88
262 sslContext->errorStr = QSslSocket::tr("Error loading local certificate, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());-
263 sslContext->errorCode = QSslError::UnspecifiedError;-
264 return;
never executed: return;
0
265 }-
266-
267 if (configuration.d->privateKey.algorithm() == QSsl::Opaque) {
configuration....= QSsl::OpaqueDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 84 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
4-84
268 sslContext->pkey = reinterpret_cast<EVP_PKEY *>(configuration.d->privateKey.handle());-
269 } else {
executed 4 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
4
270 // Load private key-
271 sslContext->pkey = q_EVP_PKEY_new();-
272 // before we were using EVP_PKEY_assign_R* functions and did not use EVP_PKEY_free.-
273 // this lead to a memory leak. Now we use the *_set1_* functions which do not-
274 // take ownership of the RSA/DSA key instance because the QSslKey already has ownership.-
275 if (configuration.d->privateKey.algorithm() == QSsl::Rsa)
configuration....) == QSsl::RsaDescription
TRUEevaluated 84 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEnever evaluated
0-84
276 q_EVP_PKEY_set1_RSA(sslContext->pkey, reinterpret_cast<RSA *>(configuration.d->privateKey.handle()));
executed 84 times by 2 tests: q_EVP_PKEY_set1_RSA(sslContext->pkey, reinterpret_cast<RSA *>(configuration.d->privateKey.handle()));
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
84
277 else if (configuration.d->privateKey.algorithm() == QSsl::Dsa)
configuration....) == QSsl::DsaDescription
TRUEnever evaluated
FALSEnever evaluated
0
278 q_EVP_PKEY_set1_DSA(sslContext->pkey, reinterpret_cast<DSA *>(configuration.d->privateKey.handle()));
never executed: q_EVP_PKEY_set1_DSA(sslContext->pkey, reinterpret_cast<DSA *>(configuration.d->privateKey.handle()));
0
279#ifndef OPENSSL_NO_EC-
280 else if (configuration.d->privateKey.algorithm() == QSsl::Ec)
configuration....() == QSsl::EcDescription
TRUEnever evaluated
FALSEnever evaluated
0
281 q_EVP_PKEY_set1_EC_KEY(sslContext->pkey, reinterpret_cast<EC_KEY *>(configuration.d->privateKey.handle()));
never executed: q_EVP_PKEY_set1_EC_KEY(sslContext->pkey, reinterpret_cast<EC_KEY *>(configuration.d->privateKey.handle()));
0
282#endif-
283 }
executed 84 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
84
284-
285 if (!q_SSL_CTX_use_PrivateKey(sslContext->ctx, sslContext->pkey)) {
!q_SSL_CTX_use...Context->pkey)Description
TRUEnever evaluated
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
0-88
286 sslContext->errorStr = QSslSocket::tr("Error loading private key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());-
287 sslContext->errorCode = QSslError::UnspecifiedError;-
288 return;
never executed: return;
0
289 }-
290 if (configuration.d->privateKey.algorithm() == QSsl::Opaque)
configuration....= QSsl::OpaqueDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 84 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
4-84
291 sslContext->pkey = 0; // Don't free the private key, it belongs to QSslKey
executed 4 times by 1 test: sslContext->pkey = 0;
Executed by:
  • tst_qsslsocket - unknown status
4
292-
293 // Check if the certificate matches the private key.-
294 if (!q_SSL_CTX_check_private_key(sslContext->ctx)) {
!q_SSL_CTX_che...lContext->ctx)Description
TRUEnever evaluated
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
0-88
295 sslContext->errorStr = QSslSocket::tr("Private key does not certify public key, %1").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl());-
296 sslContext->errorCode = QSslError::UnspecifiedError;-
297 return;
never executed: return;
0
298 }-
299-
300 // If we have any intermediate certificates then we need to add them to our chain-
301 bool first = true;-
302 for (const QSslCertificate &cert : qAsConst(configuration.d->localCertificateChain)) {-
303 if (first) {
firstDescription
TRUEevaluated 88 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5-88
304 first = false;-
305 continue;
executed 88 times by 2 tests: continue;
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
88
306 }-
307 q_SSL_CTX_ctrl(sslContext->ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0,-
308 q_X509_dup(reinterpret_cast<X509 *>(cert.handle())));-
309 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
5
310 }
executed 88 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
88
311-
312 // Initialize peer verification.-
313 if (sslContext->sslConfiguration.peerVerifyMode() == QSslSocket::VerifyNone) {
sslContext->ss...et::VerifyNoneDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 443 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
7-443
314 q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_NONE, 0);-
315 } else {
executed 7 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
7
316 q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_PEER, q_X509Callback);-
317 }
executed 443 times by 7 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
443
318-
319 // Set verification depth.-
320 if (sslContext->sslConfiguration.peerVerifyDepth() != 0)
sslContext->ss...fyDepth() != 0Description
TRUEnever evaluated
FALSEevaluated 450 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
0-450
321 q_SSL_CTX_set_verify_depth(sslContext->ctx, sslContext->sslConfiguration.peerVerifyDepth());
never executed: q_SSL_CTX_set_verify_depth(sslContext->ctx, sslContext->sslConfiguration.peerVerifyDepth());
0
322-
323 // set persisted session if the user set it-
324 if (!configuration.sessionTicket().isEmpty())
!configuration...et().isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 449 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
1-449
325 sslContext->setSessionASN1(configuration.sessionTicket());
executed 1 time by 1 test: sslContext->setSessionASN1(configuration.sessionTicket());
Executed by:
  • tst_QNetworkReply
1
326-
327 // Set temp DH params-
328 DH *dh = 0;-
329 dh = get_dh1024();-
330 q_SSL_CTX_set_tmp_dh(sslContext->ctx, dh);-
331 q_DH_free(dh);-
332-
333#ifndef OPENSSL_NO_EC-
334#if OPENSSL_VERSION_NUMBER >= 0x10002000L-
335 if (q_SSLeay() >= 0x10002000L) {-
336 q_SSL_CTX_ctrl(sslContext->ctx, SSL_CTRL_SET_ECDH_AUTO, 1, NULL);-
337 } else-
338#endif-
339 {-
340 // Set temp ECDH params-
341 EC_KEY *ecdh = 0;-
342 ecdh = q_EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);-
343 q_SSL_CTX_set_tmp_ecdh(sslContext->ctx, ecdh);-
344 q_EC_KEY_free(ecdh);-
345 }-
346#endif // OPENSSL_NO_EC-
347-
348 const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();-
349 if (!qcurves.isEmpty()) {
!qcurves.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 450 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
0-450
350#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)-
351 // Set the curves to be used-
352 if (q_SSLeay() >= 0x10002000L) {-
353 // SSL_CTX_ctrl wants a non-const pointer as last argument,-
354 // but let's avoid a copy into a temporary array-
355 if (!q_SSL_CTX_ctrl(sslContext->ctx,-
356 SSL_CTRL_SET_CURVES,-
357 qcurves.size(),-
358 const_cast<int *>(reinterpret_cast<const int *>(qcurves.data())))) {-
359 sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocketBackendPrivate::getErrorsFromOpenSsl());-
360 sslContext->errorCode = QSslError::UnspecifiedError;-
361 }-
362 } else-
363#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)-
364 {-
365 // specific curves requested, but not possible to set -> error-
366 sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version too old, need at least v1.0.2"));-
367 sslContext->errorCode = QSslError::UnspecifiedError;-
368 }-
369 }
never executed: end of block
0
370}
executed 450 times by 7 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
450
371-
372QSslContext* QSslContext::fromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading)-
373{-
374 QSslContext *sslContext = new QSslContext();-
375 initSslContext(sslContext, mode, configuration, allowRootCertOnDemandLoading);-
376 return sslContext;
never executed: return sslContext;
0
377}-
378-
379QSharedPointer<QSslContext> QSslContext::sharedFromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading)-
380{-
381 QSharedPointer<QSslContext> sslContext = QSharedPointer<QSslContext>::create();-
382 initSslContext(sslContext.data(), mode, configuration, allowRootCertOnDemandLoading);-
383 return sslContext;
executed 458 times by 7 tests: return sslContext;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
458
384}-
385-
386#if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG)-
387-
388static int next_proto_cb(SSL *, unsigned char **out, unsigned char *outlen,-
389 const unsigned char *in, unsigned int inlen, void *arg)-
390{-
391 QSslContext::NPNContext *ctx = reinterpret_cast<QSslContext::NPNContext *>(arg);-
392-
393 // comment out to debug:-
394// QList<QByteArray> supportedVersions;-
395// for (unsigned int i = 0; i < inlen; ) {-
396// QByteArray version(reinterpret_cast<const char *>(&in[i+1]), in[i]);-
397// supportedVersions << version;-
398// i += in[i] + 1;-
399// }-
400-
401 int proto = q_SSL_select_next_proto(out, outlen, in, inlen, ctx->data, ctx->len);-
402 switch (proto) {-
403 case OPENSSL_NPN_UNSUPPORTED:
never executed: case 0:
0
404 ctx->status = QSslConfiguration::NextProtocolNegotiationNone;-
405 break;
never executed: break;
0
406 case OPENSSL_NPN_NEGOTIATED:
executed 7 times by 1 test: case 1:
Executed by:
  • tst_Spdy
7
407 ctx->status = QSslConfiguration::NextProtocolNegotiationNegotiated;-
408 break;
executed 7 times by 1 test: break;
Executed by:
  • tst_Spdy
7
409 case OPENSSL_NPN_NO_OVERLAP:
never executed: case 2:
0
410 ctx->status = QSslConfiguration::NextProtocolNegotiationUnsupported;-
411 break;
never executed: break;
0
412 default:
never executed: default:
0
413 qCWarning(lcSsl, "OpenSSL sent unknown NPN status");
never executed: QMessageLogger(__FILE__, 413, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("OpenSSL sent unknown NPN status");
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
414 }
never executed: end of block
0
415-
416 return SSL_TLSEXT_ERR_OK;
executed 7 times by 1 test: return 0;
Executed by:
  • tst_Spdy
7
417}-
418-
419QSslContext::NPNContext QSslContext::npnContext() const-
420{-
421 return m_npnContext;
executed 710 times by 7 tests: return m_npnContext;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
710
422}-
423#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...-
424-
425// Needs to be deleted by caller-
426SSL* QSslContext::createSsl()-
427{-
428 SSL* ssl = q_SSL_new(ctx);-
429 q_SSL_clear(ssl);-
430-
431 if (!session && !sessionASN1().isEmpty()
!sessionDescription
TRUEevaluated 461 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_QNetworkReply
!sessionASN1().isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 460 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
1-461
432 && !sslConfiguration.testSslOption(QSsl::SslOptionDisableSessionPersistence)) {
!sslConfigurat...onPersistence)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-1
433 const unsigned char *data = reinterpret_cast<const unsigned char *>(m_sessionASN1.constData());-
434 session = q_d2i_SSL_SESSION(0, &data, m_sessionASN1.size()); // refcount is 1 already, set by function above-
435 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
436-
437 if (session) {
sessionDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 460 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
16-460
438 // Try to resume the last session we cached-
439 if (!q_SSL_set_session(ssl, session)) {
!q_SSL_set_ses...(ssl, session)Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-16
440 qCWarning(lcSsl, "could not set SSL session");
never executed: QMessageLogger(__FILE__, 440, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("could not set SSL session");
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
441 q_SSL_SESSION_free(session);-
442 session = 0;-
443 }
never executed: end of block
0
444 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
16
445-
446#if OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_NEXTPROTONEG)-
447 QList<QByteArray> protocols = sslConfiguration.d->nextAllowedProtocols;-
448 if (!protocols.isEmpty()) {
!protocols.isEmpty()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 469 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
7-469
449 m_supportedNPNVersions.clear();-
450 for (int a = 0; a < protocols.count(); ++a) {
a < protocols.count()Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_Spdy
7-14
451 if (protocols.at(a).size() > 255) {
protocols.at(a).size() > 255Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_Spdy
0-14
452 qCWarning(lcSsl) << "TLS NPN extension" << protocols.at(a)
never executed: QMessageLogger(__FILE__, 452, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning() << "TLS NPN extension" << protocols.at(a) << "is too long and will be truncated to 255 characters.";
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
453 << "is too long and will be truncated to 255 characters.";
never executed: QMessageLogger(__FILE__, 452, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning() << "TLS NPN extension" << protocols.at(a) << "is too long and will be truncated to 255 characters.";
0
454 protocols[a] = protocols.at(a).left(255);-
455 }
never executed: end of block
0
456 m_supportedNPNVersions.append(protocols.at(a).size()).append(protocols.at(a));-
457 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_Spdy
14
458 m_npnContext.data = reinterpret_cast<unsigned char *>(m_supportedNPNVersions.data());-
459 m_npnContext.len = m_supportedNPNVersions.count();-
460 m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone;-
461 q_SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &m_npnContext);-
462 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_Spdy
7
463#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...-
464-
465 return ssl;
executed 476 times by 7 tests: return ssl;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
476
466}-
467-
468// We cache exactly one session here-
469bool QSslContext::cacheSession(SSL* ssl)-
470{-
471 // don't cache the same session again-
472 if (session && session == q_SSL_get_session(ssl))
sessionDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 333 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
session == q_S...t_session(ssl)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-333
473 return true;
executed 16 times by 1 test: return true;
Executed by:
  • tst_QNetworkReply
16
474-
475 // decrease refcount of currently stored session-
476 // (this might happen if there are several concurrent handshakes in flight)-
477 if (session)
sessionDescription
TRUEnever evaluated
FALSEevaluated 333 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
0-333
478 q_SSL_SESSION_free(session);
never executed: q_SSL_SESSION_free(session);
0
479-
480 // cache the session the caller gave us and increase reference count-
481 session = q_SSL_get1_session(ssl);-
482-
483 if (session && !sslConfiguration.testSslOption(QSsl::SslOptionDisableSessionPersistence)) {
sessionDescription
TRUEevaluated 333 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEnever evaluated
!sslConfigurat...onPersistence)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 332 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
0-333
484 int sessionSize = q_i2d_SSL_SESSION(session, 0);-
485 if (sessionSize > 0) {
sessionSize > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-1
486 m_sessionASN1.resize(sessionSize);-
487 unsigned char *data = reinterpret_cast<unsigned char *>(m_sessionASN1.data());-
488 if (!q_i2d_SSL_SESSION(session, &data))
!q_i2d_SSL_SES...ession, &data)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
0-1
489 qCWarning(lcSsl, "could not store persistent version of SSL session");
never executed: QMessageLogger(__FILE__, 489, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("could not store persistent version of SSL session");
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
490 m_sessionTicketLifeTimeHint = session->tlsext_tick_lifetime_hint;-
491 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
492 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
493-
494 return (session != 0);
executed 333 times by 7 tests: return (session != 0);
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
333
495}-
496-
497QByteArray QSslContext::sessionASN1() const-
498{-
499 return m_sessionASN1;
executed 465 times by 7 tests: return m_sessionASN1;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
465
500}-
501-
502void QSslContext::setSessionASN1(const QByteArray &session)-
503{-
504 m_sessionASN1 = session;-
505}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
506-
507int QSslContext::sessionTicketLifeTimeHint() const-
508{-
509 return m_sessionTicketLifeTimeHint;
executed 2 times by 1 test: return m_sessionTicketLifeTimeHint;
Executed by:
  • tst_QNetworkReply
2
510}-
511-
512QSslError::SslError QSslContext::error() const-
513{-
514 return errorCode;
executed 484 times by 7 tests: return errorCode;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
484
515}-
516-
517QString QSslContext::errorString() const-
518{-
519 return errorStr;
executed 8 times by 2 tests: return errorStr;
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
8
520}-
521-
522QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9