qsslsocket.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qsslsocket.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Copyright (C) 2014 BlackBerry Limited. All rights reserved.-
5** Contact: http://www.qt.io/licensing/-
6**-
7** This file is part of the QtNetwork module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL21$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see http://www.qt.io/terms-conditions. For further-
16** information use the contact form at http://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 2.1 or version 3 as published by the Free-
21** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
22** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
23** following information to ensure the GNU Lesser General Public License-
24** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
25** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
26**-
27** As a special exception, The Qt Company gives you certain additional-
28** rights. These rights are described in The Qt Company LGPL Exception-
29** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
30**-
31** $QT_END_LICENSE$-
32**-
33****************************************************************************/-
34-
35-
36//#define QSSLSOCKET_DEBUG-
37-
38/*!-
39 \class QSslSocket-
40 \brief The QSslSocket class provides an SSL encrypted socket for both-
41 clients and servers.-
42 \since 4.3-
43-
44 \reentrant-
45 \ingroup network-
46 \ingroup ssl-
47 \inmodule QtNetwork-
48-
49 QSslSocket establishes a secure, encrypted TCP connection you can-
50 use for transmitting encrypted data. It can operate in both client-
51 and server mode, and it supports modern SSL protocols, including-
52 SSL 3 and TLS 1.2. By default, QSslSocket uses only SSL protocols-
53 which are considered to be secure (QSsl::SecureProtocols), but you can-
54 change the SSL protocol by calling setProtocol() as long as you do-
55 it before the handshake has started.-
56-
57 SSL encryption operates on top of the existing TCP stream after-
58 the socket enters the ConnectedState. There are two simple ways to-
59 establish a secure connection using QSslSocket: With an immediate-
60 SSL handshake, or with a delayed SSL handshake occurring after the-
61 connection has been established in unencrypted mode.-
62-
63 The most common way to use QSslSocket is to construct an object-
64 and start a secure connection by calling connectToHostEncrypted().-
65 This method starts an immediate SSL handshake once the connection-
66 has been established.-
67-
68 \snippet code/src_network_ssl_qsslsocket.cpp 0-
69-
70 As with a plain QTcpSocket, QSslSocket enters the HostLookupState,-
71 ConnectingState, and finally the ConnectedState, if the connection-
72 is successful. The handshake then starts automatically, and if it-
73 succeeds, the encrypted() signal is emitted to indicate the socket-
74 has entered the encrypted state and is ready for use.-
75-
76 Note that data can be written to the socket immediately after the-
77 return from connectToHostEncrypted() (i.e., before the encrypted()-
78 signal is emitted). The data is queued in QSslSocket until after-
79 the encrypted() signal is emitted.-
80-
81 An example of using the delayed SSL handshake to secure an-
82 existing connection is the case where an SSL server secures an-
83 incoming connection. Suppose you create an SSL server class as a-
84 subclass of QTcpServer. You would override-
85 QTcpServer::incomingConnection() with something like the example-
86 below, which first constructs an instance of QSslSocket and then-
87 calls setSocketDescriptor() to set the new socket's descriptor to-
88 the existing one passed in. It then initiates the SSL handshake-
89 by calling startServerEncryption().-
90-
91 \snippet code/src_network_ssl_qsslsocket.cpp 1-
92-
93 If an error occurs, QSslSocket emits the sslErrors() signal. In this-
94 case, if no action is taken to ignore the error(s), the connection-
95 is dropped. To continue, despite the occurrence of an error, you-
96 can call ignoreSslErrors(), either from within this slot after the-
97 error occurs, or any time after construction of the QSslSocket and-
98 before the connection is attempted. This will allow QSslSocket to-
99 ignore the errors it encounters when establishing the identity of-
100 the peer. Ignoring errors during an SSL handshake should be used-
101 with caution, since a fundamental characteristic of secure-
102 connections is that they should be established with a successful-
103 handshake.-
104-
105 Once encrypted, you use QSslSocket as a regular QTcpSocket. When-
106 readyRead() is emitted, you can call read(), canReadLine() and-
107 readLine(), or getChar() to read decrypted data from QSslSocket's-
108 internal buffer, and you can call write() or putChar() to write-
109 data back to the peer. QSslSocket will automatically encrypt the-
110 written data for you, and emit encryptedBytesWritten() once-
111 the data has been written to the peer.-
112-
113 As a convenience, QSslSocket supports QTcpSocket's blocking-
114 functions waitForConnected(), waitForReadyRead(),-
115 waitForBytesWritten(), and waitForDisconnected(). It also provides-
116 waitForEncrypted(), which will block the calling thread until an-
117 encrypted connection has been established.-
118-
119 \snippet code/src_network_ssl_qsslsocket.cpp 2-
120-
121 QSslSocket provides an extensive, easy-to-use API for handling-
122 cryptographic ciphers, private keys, and local, peer, and-
123 Certification Authority (CA) certificates. It also provides an API-
124 for handling errors that occur during the handshake phase.-
125-
126 The following features can also be customized:-
127-
128 \list-
129 \li The socket's cryptographic cipher suite can be customized before-
130 the handshake phase with setCiphers() and setDefaultCiphers().-
131 \li The socket's local certificate and private key can be customized-
132 before the handshake phase with setLocalCertificate() and-
133 setPrivateKey().-
134 \li The CA certificate database can be extended and customized with-
135 addCaCertificate(), addCaCertificates(), addDefaultCaCertificate(),-
136 addDefaultCaCertificates(), and QSslConfiguration::defaultConfiguration().setCaCertificates().-
137 \endlist-
138-
139 \note If available, root certificates on Unix (excluding \macos) will be-
140 loaded on demand from the standard certificate directories. If you do not-
141 want to load root certificates on demand, you need to call either-
142 QSslConfiguration::defaultConfiguration().setCaCertificates() before the first-
143 SSL handshake is made in your application (for example, via passing-
144 QSslSocket::systemCaCertificates() to it), or call-
145 QSslConfiguration::defaultConfiguration()::setCaCertificates() on your QSslSocket instance-
146 prior to the SSL handshake.-
147-
148 For more information about ciphers and certificates, refer to QSslCipher and-
149 QSslCertificate.-
150-
151 This product includes software developed by the OpenSSL Project-
152 for use in the OpenSSL Toolkit (\l{http://www.openssl.org/}).-
153-
154 \note Be aware of the difference between the bytesWritten() signal and-
155 the encryptedBytesWritten() signal. For a QTcpSocket, bytesWritten()-
156 will get emitted as soon as data has been written to the TCP socket.-
157 For a QSslSocket, bytesWritten() will get emitted when the data-
158 is being encrypted and encryptedBytesWritten()-
159 will get emitted as soon as data has been written to the TCP socket.-
160-
161 \sa QSslCertificate, QSslCipher, QSslError-
162*/-
163-
164/*!-
165 \enum QSslSocket::SslMode-
166-
167 Describes the connection modes available for QSslSocket.-
168-
169 \value UnencryptedMode The socket is unencrypted. Its-
170 behavior is identical to QTcpSocket.-
171-
172 \value SslClientMode The socket is a client-side SSL socket.-
173 It is either alreayd encrypted, or it is in the SSL handshake-
174 phase (see QSslSocket::isEncrypted()).-
175-
176 \value SslServerMode The socket is a server-side SSL socket.-
177 It is either already encrypted, or it is in the SSL handshake-
178 phase (see QSslSocket::isEncrypted()).-
179*/-
180-
181/*!-
182 \enum QSslSocket::PeerVerifyMode-
183 \since 4.4-
184-
185 Describes the peer verification modes for QSslSocket. The default mode is-
186 AutoVerifyPeer, which selects an appropriate mode depending on the-
187 socket's QSocket::SslMode.-
188-
189 \value VerifyNone QSslSocket will not request a certificate from the-
190 peer. You can set this mode if you are not interested in the identity of-
191 the other side of the connection. The connection will still be encrypted,-
192 and your socket will still send its local certificate to the peer if it's-
193 requested.-
194-
195 \value QueryPeer QSslSocket will request a certificate from the peer, but-
196 does not require this certificate to be valid. This is useful when you-
197 want to display peer certificate details to the user without affecting the-
198 actual SSL handshake. This mode is the default for servers.-
199-
200 \value VerifyPeer QSslSocket will request a certificate from the peer-
201 during the SSL handshake phase, and requires that this certificate is-
202 valid. On failure, QSslSocket will emit the QSslSocket::sslErrors()-
203 signal. This mode is the default for clients.-
204-
205 \value AutoVerifyPeer QSslSocket will automatically use QueryPeer for-
206 server sockets and VerifyPeer for client sockets.-
207-
208 \sa QSslSocket::peerVerifyMode()-
209*/-
210-
211/*!-
212 \fn QSslSocket::encrypted()-
213-
214 This signal is emitted when QSslSocket enters encrypted mode. After this-
215 signal has been emitted, QSslSocket::isEncrypted() will return true, and-
216 all further transmissions on the socket will be encrypted.-
217-
218 \sa QSslSocket::connectToHostEncrypted(), QSslSocket::isEncrypted()-
219*/-
220-
221/*!-
222 \fn QSslSocket::modeChanged(QSslSocket::SslMode mode)-
223-
224 This signal is emitted when QSslSocket changes from \l-
225 QSslSocket::UnencryptedMode to either \l QSslSocket::SslClientMode or \l-
226 QSslSocket::SslServerMode. \a mode is the new mode.-
227-
228 \sa QSslSocket::mode()-
229*/-
230-
231/*!-
232 \fn QSslSocket::encryptedBytesWritten(qint64 written)-
233 \since 4.4-
234-
235 This signal is emitted when QSslSocket writes its encrypted data to the-
236 network. The \a written parameter contains the number of bytes that were-
237 successfully written.-
238-
239 \sa QIODevice::bytesWritten()-
240*/-
241-
242/*!-
243 \fn void QSslSocket::peerVerifyError(const QSslError &error)-
244 \since 4.4-
245-
246 QSslSocket can emit this signal several times during the SSL handshake,-
247 before encryption has been established, to indicate that an error has-
248 occurred while establishing the identity of the peer. The \a error is-
249 usually an indication that QSslSocket is unable to securely identify the-
250 peer.-
251-
252 This signal provides you with an early indication when something's wrong.-
253 By connecting to this signal, you can manually choose to tear down the-
254 connection from inside the connected slot before the handshake has-
255 completed. If no action is taken, QSslSocket will proceed to emitting-
256 QSslSocket::sslErrors().-
257-
258 \sa sslErrors()-
259*/-
260-
261/*!-
262 \fn void QSslSocket::sslErrors(const QList<QSslError> &errors);-
263-
264 QSslSocket emits this signal after the SSL handshake to indicate that one-
265 or more errors have occurred while establishing the identity of the-
266 peer. The errors are usually an indication that QSslSocket is unable to-
267 securely identify the peer. Unless any action is taken, the connection-
268 will be dropped after this signal has been emitted.-
269-
270 If you want to continue connecting despite the errors that have occurred,-
271 you must call QSslSocket::ignoreSslErrors() from inside a slot connected to-
272 this signal. If you need to access the error list at a later point, you-
273 can call sslErrors() (without arguments).-
274-
275 \a errors contains one or more errors that prevent QSslSocket from-
276 verifying the identity of the peer.-
277-
278 \note You cannot use Qt::QueuedConnection when connecting to this signal,-
279 or calling QSslSocket::ignoreSslErrors() will have no effect.-
280-
281 \sa peerVerifyError()-
282*/-
283-
284/*!-
285 \fn void QSslSocket::preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator)-
286 \since 5.5-
287-
288 QSslSocket emits this signal when it negotiates a PSK ciphersuite, and-
289 therefore a PSK authentication is then required.-
290-
291 When using PSK, the client must send to the server a valid identity and a-
292 valid pre shared key, in order for the SSL handshake to continue.-
293 Applications can provide this information in a slot connected to this-
294 signal, by filling in the passed \a authenticator object according to their-
295 needs.-
296-
297 \note Ignoring this signal, or failing to provide the required credentials,-
298 will cause the handshake to fail, and therefore the connection to be aborted.-
299-
300 \note The \a authenticator object is owned by the socket and must not be-
301 deleted by the application.-
302-
303 \sa QSslPreSharedKeyAuthenticator-
304*/-
305-
306#include "qssl_p.h"-
307#include "qsslsocket.h"-
308#include "qsslcipher.h"-
309#ifndef QT_NO_OPENSSL-
310#include "qsslsocket_openssl_p.h"-
311#endif-
312#ifdef Q_OS_WINRT-
313#include "qsslsocket_winrt_p.h"-
314#endif-
315#ifdef QT_SECURETRANSPORT-
316#include "qsslsocket_mac_p.h"-
317#endif-
318#include "qsslconfiguration_p.h"-
319-
320#include <QtCore/qdebug.h>-
321#include <QtCore/qdir.h>-
322#include <QtCore/qmutex.h>-
323#include <QtCore/qelapsedtimer.h>-
324#include <QtNetwork/qhostaddress.h>-
325#include <QtNetwork/qhostinfo.h>-
326-
327QT_BEGIN_NAMESPACE-
328-
329class QSslSocketGlobalData-
330{-
331public:-
332 QSslSocketGlobalData() : config(new QSslConfigurationPrivate) {}
executed 15 times by 15 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
15
333-
334 QMutex mutex;-
335 QList<QSslCipher> supportedCiphers;-
336 QVector<QSslEllipticCurve> supportedEllipticCurves;-
337 QExplicitlySharedDataPointer<QSslConfigurationPrivate> config;-
338};-
339Q_GLOBAL_STATIC(QSslSocketGlobalData, globalData)
executed 15 times by 15 tests: end of block
Executed by:
  • tst_networkselftest - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_spdy - unknown status
executed 15 times by 15 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_networkselftest - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_spdy - unknown status
executed 4198 times by 16 tests: return &holder.value;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
guard.load() =...c::InitializedDescription
TRUEevaluated 15 times by 15 tests
Evaluated by:
  • tst_networkselftest - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_spdy - unknown status
FALSEnever evaluated
0-4198
340-
341/*!-
342 Constructs a QSslSocket object. \a parent is passed to QObject's-
343 constructor. The new socket's \l {QSslCipher} {cipher} suite is-
344 set to the one returned by the static method defaultCiphers().-
345*/-
346QSslSocket::QSslSocket(QObject *parent)-
347 : QTcpSocket(*new QSslSocketBackendPrivate, parent)-
348{-
349 Q_D(QSslSocket);-
350#ifdef QSSLSOCKET_DEBUG-
351 qCDebug(lcSsl) << "QSslSocket::QSslSocket(" << parent << "), this =" << (void *)this;-
352#endif-
353 d->q_ptr = this;-
354 d->init();-
355}
executed 713 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_qtcpsocket - unknown status
713
356-
357/*!-
358 Destroys the QSslSocket.-
359*/-
360QSslSocket::~QSslSocket()-
361{-
362 Q_D(QSslSocket);-
363#ifdef QSSLSOCKET_DEBUG-
364 qCDebug(lcSsl) << "QSslSocket::~QSslSocket(), this =" << (void *)this;-
365#endif-
366 delete d->plainSocket;-
367 d->plainSocket = 0;-
368}
executed 707 times by 9 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_qtcpsocket - unknown status
  • tst_spdy - unknown status
707
369-
370/*!-
371 \reimp-
372-
373 \since 5.0-
374-
375 Continues data transfer on the socket after it has been paused. If-
376 "setPauseMode(QAbstractSocket::PauseOnSslErrors);" has been called on-
377 this socket and a sslErrors() signal is received, calling this method-
378 is necessary for the socket to continue.-
379-
380 \sa QAbstractSocket::pauseMode(), QAbstractSocket::setPauseMode()-
381*/-
382void QSslSocket::resume()-
383{-
384 // continuing might emit signals, rather do this through the event loop-
385 QMetaObject::invokeMethod(this, "_q_resumeImplementation", Qt::QueuedConnection);-
386}
executed 20 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
20
387-
388/*!-
389 Starts an encrypted connection to the device \a hostName on \a-
390 port, using \a mode as the \l OpenMode. This is equivalent to-
391 calling connectToHost() to establish the connection, followed by a-
392 call to startClientEncryption(). The \a protocol parameter can be-
393 used to specify which network protocol to use (eg. IPv4 or IPv6).-
394-
395 QSslSocket first enters the HostLookupState. Then, after entering-
396 either the event loop or one of the waitFor...() functions, it-
397 enters the ConnectingState, emits connected(), and then initiates-
398 the SSL client handshake. At each state change, QSslSocket emits-
399 signal stateChanged().-
400-
401 After initiating the SSL client handshake, if the identity of the-
402 peer can't be established, signal sslErrors() is emitted. If you-
403 want to ignore the errors and continue connecting, you must call-
404 ignoreSslErrors(), either from inside a slot function connected to-
405 the sslErrors() signal, or prior to entering encrypted mode. If-
406 ignoreSslErrors() is not called, the connection is dropped, signal-
407 disconnected() is emitted, and QSslSocket returns to the-
408 UnconnectedState.-
409-
410 If the SSL handshake is successful, QSslSocket emits encrypted().-
411-
412 \snippet code/src_network_ssl_qsslsocket.cpp 3-
413-
414 \note The example above shows that text can be written to-
415 the socket immediately after requesting the encrypted connection,-
416 before the encrypted() signal has been emitted. In such cases, the-
417 text is queued in the object and written to the socket \e after-
418 the connection is established and the encrypted() signal has been-
419 emitted.-
420-
421 The default for \a mode is \l ReadWrite.-
422-
423 If you want to create a QSslSocket on the server side of a connection, you-
424 should instead call startServerEncryption() upon receiving the incoming-
425 connection through QTcpServer.-
426-
427 \sa connectToHost(), startClientEncryption(), waitForConnected(), waitForEncrypted()-
428*/-
429void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode, NetworkLayerProtocol protocol)-
430{-
431 Q_D(QSslSocket);-
432 if (d->state == ConnectedState || d->state == ConnectingState) {
d->state == ConnectedStateDescription
TRUEnever evaluated
FALSEevaluated 402 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
d->state == ConnectingStateDescription
TRUEnever evaluated
FALSEevaluated 402 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
0-402
433 qCWarning(lcSsl,
never executed: QMessageLogger( __FILE__ , 434 , __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::connectToHostEncrypted() called when already connecting/connected") ;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
434 "QSslSocket::connectToHostEncrypted() called when already connecting/connected");
never executed: QMessageLogger( __FILE__ , 434 , __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::connectToHostEncrypted() called when already connecting/connected") ;
0
435 return;
never executed: return;
0
436 }-
437-
438 d->init();-
439 d->autoStartHandshake = true;-
440 d->initialized = true;-
441-
442 // Note: When connecting to localhost, some platforms (e.g., HP-UX and some BSDs)-
443 // establish the connection immediately (i.e., first attempt).-
444 connectToHost(hostName, port, mode, protocol);-
445}
executed 402 times by 6 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
402
446-
447/*!-
448 \since 4.6-
449 \overload-
450-
451 In addition to the original behaviour of connectToHostEncrypted,-
452 this overloaded method enables the usage of a different hostname-
453 (\a sslPeerName) for the certificate validation instead of-
454 the one used for the TCP connection (\a hostName).-
455-
456 \sa connectToHostEncrypted()-
457*/-
458void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port,-
459 const QString &sslPeerName, OpenMode mode,-
460 NetworkLayerProtocol protocol)-
461{-
462 Q_D(QSslSocket);-
463 if (d->state == ConnectedState || d->state == ConnectingState) {
d->state == ConnectedStateDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
d->state == ConnectingStateDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
0-5
464 qCWarning(lcSsl,
never executed: QMessageLogger( __FILE__ , 465 , __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::connectToHostEncrypted() called when already connecting/connected") ;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
465 "QSslSocket::connectToHostEncrypted() called when already connecting/connected");
never executed: QMessageLogger( __FILE__ , 465 , __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::connectToHostEncrypted() called when already connecting/connected") ;
0
466 return;
never executed: return;
0
467 }-
468-
469 d->init();-
470 d->autoStartHandshake = true;-
471 d->initialized = true;-
472 d->verificationPeerName = sslPeerName;-
473-
474 // Note: When connecting to localhost, some platforms (e.g., HP-UX and some BSDs)-
475 // establish the connection immediately (i.e., first attempt).-
476 connectToHost(hostName, port, mode, protocol);-
477}
executed 5 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
5
478-
479/*!-
480 Initializes QSslSocket with the native socket descriptor \a-
481 socketDescriptor. Returns \c true if \a socketDescriptor is accepted-
482 as a valid socket descriptor; otherwise returns \c false.-
483 The socket is opened in the mode specified by \a openMode, and-
484 enters the socket state specified by \a state.-
485-
486 \note It is not possible to initialize two sockets with the same-
487 native socket descriptor.-
488-
489 \sa socketDescriptor()-
490*/-
491bool QSslSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState state, OpenMode openMode)-
492{-
493 Q_D(QSslSocket);-
494#ifdef QSSLSOCKET_DEBUG-
495 qCDebug(lcSsl) << "QSslSocket::setSocketDescriptor(" << socketDescriptor << ','-
496 << state << ',' << openMode << ')';-
497#endif-
498 if (!d->plainSocket)
!d->plainSocketDescription
TRUEevaluated 67 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-67
499 d->createPlainSocket(openMode);
executed 67 times by 3 tests: d->createPlainSocket(openMode);
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
67
500 bool retVal = d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode);-
501 d->cachedSocketDescriptor = d->plainSocket->socketDescriptor();-
502 d->setError(d->plainSocket->error(), d->plainSocket->errorString());-
503 setSocketState(state);-
504 setOpenMode(openMode);-
505 setLocalPort(d->plainSocket->localPort());-
506 setLocalAddress(d->plainSocket->localAddress());-
507 setPeerPort(d->plainSocket->peerPort());-
508 setPeerAddress(d->plainSocket->peerAddress());-
509 setPeerName(d->plainSocket->peerName());-
510 return retVal;
executed 67 times by 3 tests: return retVal;
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
67
511}-
512-
513/*!-
514 \since 4.6-
515 Sets the given \a option to the value described by \a value.-
516-
517 \sa socketOption()-
518*/-
519void QSslSocket::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)-
520{-
521 Q_D(QSslSocket);-
522 if (d->plainSocket)
d->plainSocketDescription
TRUEevaluated 120 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-120
523 d->plainSocket->setSocketOption(option, value);
executed 120 times by 3 tests: d->plainSocket->setSocketOption(option, value);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
120
524}
executed 120 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
120
525-
526/*!-
527 \since 4.6-
528 Returns the value of the \a option option.-
529-
530 \sa setSocketOption()-
531*/-
532QVariant QSslSocket::socketOption(QAbstractSocket::SocketOption option)-
533{-
534 Q_D(QSslSocket);-
535 if (d->plainSocket)
d->plainSocketDescription
TRUEnever evaluated
FALSEnever evaluated
0
536 return d->plainSocket->socketOption(option);
never executed: return d->plainSocket->socketOption(option);
0
537 else-
538 return QVariant();
never executed: return QVariant();
0
539}-
540-
541/*!-
542 Returns the current mode for the socket; either UnencryptedMode, where-
543 QSslSocket behaves identially to QTcpSocket, or one of SslClientMode or-
544 SslServerMode, where the client is either negotiating or in encrypted-
545 mode.-
546-
547 When the mode changes, QSslSocket emits modeChanged()-
548-
549 \sa SslMode-
550*/-
551QSslSocket::SslMode QSslSocket::mode() const-
552{-
553 Q_D(const QSslSocket);-
554 return d->mode;
executed 24 times by 1 test: return d->mode;
Executed by:
  • tst_qsslsocket - unknown status
24
555}-
556-
557/*!-
558 Returns \c true if the socket is encrypted; otherwise, false is returned.-
559-
560 An encrypted socket encrypts all data that is written by calling write()-
561 or putChar() before the data is written to the network, and decrypts all-
562 incoming data as the data is received from the network, before you call-
563 read(), readLine() or getChar().-
564-
565 QSslSocket emits encrypted() when it enters encrypted mode.-
566-
567 You can call sessionCipher() to find which cryptographic cipher is used to-
568 encrypt and decrypt your data.-
569-
570 \sa mode()-
571*/-
572bool QSslSocket::isEncrypted() const-
573{-
574 Q_D(const QSslSocket);-
575 return d->connectionEncrypted;
executed 122 times by 1 test: return d->connectionEncrypted;
Executed by:
  • tst_qsslsocket - unknown status
122
576}-
577-
578/*!-
579 Returns the socket's SSL protocol. By default, \l QSsl::SecureProtocols is used.-
580-
581 \sa setProtocol()-
582*/-
583QSsl::SslProtocol QSslSocket::protocol() const-
584{-
585 Q_D(const QSslSocket);-
586 return d->configuration.protocol;
executed 130 times by 1 test: return d->configuration.protocol;
Executed by:
  • tst_qsslsocket - unknown status
130
587}-
588-
589/*!-
590 Sets the socket's SSL protocol to \a protocol. This will affect the next-
591 initiated handshake; calling this function on an already-encrypted socket-
592 will not affect the socket's protocol.-
593*/-
594void QSslSocket::setProtocol(QSsl::SslProtocol protocol)-
595{-
596 Q_D(QSslSocket);-
597 d->configuration.protocol = protocol;-
598}
executed 115 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
115
599-
600/*!-
601 \since 4.4-
602-
603 Returns the socket's verify mode. This mode decides whether-
604 QSslSocket should request a certificate from the peer (i.e., the client-
605 requests a certificate from the server, or a server requesting a-
606 certificate from the client), and whether it should require that this-
607 certificate is valid.-
608-
609 The default mode is AutoVerifyPeer, which tells QSslSocket to use-
610 VerifyPeer for clients and QueryPeer for servers.-
611-
612 \sa setPeerVerifyMode(), peerVerifyDepth(), mode()-
613*/-
614QSslSocket::PeerVerifyMode QSslSocket::peerVerifyMode() const-
615{-
616 Q_D(const QSslSocket);-
617 return d->configuration.peerVerifyMode;
executed 3 times by 1 test: return d->configuration.peerVerifyMode;
Executed by:
  • tst_qsslsocket - unknown status
3
618}-
619-
620/*!-
621 \since 4.4-
622-
623 Sets the socket's verify mode to \a mode. This mode decides whether-
624 QSslSocket should request a certificate from the peer (i.e., the client-
625 requests a certificate from the server, or a server requesting a-
626 certificate from the client), and whether it should require that this-
627 certificate is valid.-
628-
629 The default mode is AutoVerifyPeer, which tells QSslSocket to use-
630 VerifyPeer for clients and QueryPeer for servers.-
631-
632 Setting this mode after encryption has started has no effect on the-
633 current connection.-
634-
635 \sa peerVerifyMode(), setPeerVerifyDepth(), mode()-
636*/-
637void QSslSocket::setPeerVerifyMode(QSslSocket::PeerVerifyMode mode)-
638{-
639 Q_D(QSslSocket);-
640 d->configuration.peerVerifyMode = mode;-
641}
executed 65 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
65
642-
643/*!-
644 \since 4.4-
645-
646 Returns the maximum number of certificates in the peer's certificate chain-
647 to be checked during the SSL handshake phase, or 0 (the default) if no-
648 maximum depth has been set, indicating that the whole certificate chain-
649 should be checked.-
650-
651 The certificates are checked in issuing order, starting with the peer's-
652 own certificate, then its issuer's certificate, and so on.-
653-
654 \sa setPeerVerifyDepth(), peerVerifyMode()-
655*/-
656int QSslSocket::peerVerifyDepth() const-
657{-
658 Q_D(const QSslSocket);-
659 return d->configuration.peerVerifyDepth;
executed 15 times by 1 test: return d->configuration.peerVerifyDepth;
Executed by:
  • tst_qsslsocket - unknown status
15
660}-
661-
662/*!-
663 \since 4.4-
664-
665 Sets the maximum number of certificates in the peer's certificate chain to-
666 be checked during the SSL handshake phase, to \a depth. Setting a depth of-
667 0 means that no maximum depth is set, indicating that the whole-
668 certificate chain should be checked.-
669-
670 The certificates are checked in issuing order, starting with the peer's-
671 own certificate, then its issuer's certificate, and so on.-
672-
673 \sa peerVerifyDepth(), setPeerVerifyMode()-
674*/-
675void QSslSocket::setPeerVerifyDepth(int depth)-
676{-
677 Q_D(QSslSocket);-
678 if (depth < 0) {
depth < 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5
679 qCWarning(lcSsl, "QSslSocket::setPeerVerifyDepth: cannot set negative depth of %d", depth);
executed 5 times by 1 test: QMessageLogger(__FILE__, 679, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::setPeerVerifyDepth: cannot set negative depth of %d", depth);
Executed by:
  • tst_qsslsocket - unknown status
qt_category_enabledDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5
680 return;
executed 5 times by 1 test: return;
Executed by:
  • tst_qsslsocket - unknown status
5
681 }-
682 d->configuration.peerVerifyDepth = depth;-
683}
executed 5 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
5
684-
685/*!-
686 \since 4.8-
687-
688 Returns the different hostname for the certificate validation, as set by-
689 setPeerVerifyName or by connectToHostEncrypted.-
690-
691 \sa setPeerVerifyName(), connectToHostEncrypted()-
692*/-
693QString QSslSocket::peerVerifyName() const-
694{-
695 Q_D(const QSslSocket);-
696 return d->verificationPeerName;
never executed: return d->verificationPeerName;
0
697}-
698-
699/*!-
700 \since 4.8-
701-
702 Sets a different host name, given by \a hostName, for the certificate-
703 validation instead of the one used for the TCP connection.-
704-
705 \sa connectToHostEncrypted()-
706*/-
707void QSslSocket::setPeerVerifyName(const QString &hostName)-
708{-
709 Q_D(QSslSocket);-
710 d->verificationPeerName = hostName;-
711}
never executed: end of block
0
712-
713/*!-
714 \reimp-
715-
716 Returns the number of decrypted bytes that are immediately available for-
717 reading.-
718*/-
719qint64 QSslSocket::bytesAvailable() const-
720{-
721 Q_D(const QSslSocket);-
722 if (d->mode == UnencryptedMode)
d->mode == UnencryptedModeDescription
TRUEevaluated 886 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 18874 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
886-18874
723 return QIODevice::bytesAvailable() + (d->plainSocket ? d->plainSocket->bytesAvailable() : 0);
executed 886 times by 3 tests: return QIODevice::bytesAvailable() + (d->plainSocket ? d->plainSocket->bytesAvailable() : 0);
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
d->plainSocketDescription
TRUEevaluated 870 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
16-886
724 return QIODevice::bytesAvailable();
executed 18874 times by 5 tests: return QIODevice::bytesAvailable();
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
18874
725}-
726-
727/*!-
728 \reimp-
729-
730 Returns the number of unencrypted bytes that are waiting to be encrypted-
731 and written to the network.-
732*/-
733qint64 QSslSocket::bytesToWrite() const-
734{-
735 Q_D(const QSslSocket);-
736 if (d->mode == UnencryptedMode)
d->mode == UnencryptedModeDescription
TRUEevaluated 327 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 7596 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
327-7596
737 return d->plainSocket ? d->plainSocket->bytesToWrite() : 0;
executed 327 times by 3 tests: return d->plainSocket ? d->plainSocket->bytesToWrite() : 0;
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
d->plainSocketDescription
TRUEevaluated 322 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qtcpsocket - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5-327
738 return d->writeBuffer.size();
executed 7596 times by 3 tests: return d->writeBuffer.size();
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
7596
739}-
740-
741/*!-
742 \since 4.4-
743-
744 Returns the number of encrypted bytes that are awaiting decryption.-
745 Normally, this function will return 0 because QSslSocket decrypts its-
746 incoming data as soon as it can.-
747*/-
748qint64 QSslSocket::encryptedBytesAvailable() const-
749{-
750 Q_D(const QSslSocket);-
751 if (d->mode == UnencryptedMode)
d->mode == UnencryptedModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
752 return 0;
never executed: return 0;
0
753 return d->plainSocket->bytesAvailable();
never executed: return d->plainSocket->bytesAvailable();
0
754}-
755-
756/*!-
757 \since 4.4-
758-
759 Returns the number of encrypted bytes that are waiting to be written to-
760 the network.-
761*/-
762qint64 QSslSocket::encryptedBytesToWrite() const-
763{-
764 Q_D(const QSslSocket);-
765 if (d->mode == UnencryptedMode)
d->mode == UnencryptedModeDescription
TRUEevaluated 217 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 3037 times by 6 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_spdy - unknown status
217-3037
766 return 0;
executed 217 times by 5 tests: return 0;
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
217
767 return d->plainSocket->bytesToWrite();
executed 3037 times by 6 tests: return d->plainSocket->bytesToWrite();
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_spdy - unknown status
3037
768}-
769-
770/*!-
771 \reimp-
772-
773 Returns \c true if you can read one while line (terminated by a single ASCII-
774 '\\n' character) of decrypted characters; otherwise, false is returned.-
775*/-
776bool QSslSocket::canReadLine() const-
777{-
778 Q_D(const QSslSocket);-
779 if (d->mode == UnencryptedMode)
d->mode == UnencryptedModeDescription
TRUEevaluated 89 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
1-89
780 return QIODevice::canReadLine() || (d->plainSocket && d->plainSocket->canReadLine());
executed 89 times by 2 tests: return QIODevice::canReadLine() || (d->plainSocket && d->plainSocket->canReadLine());
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
QIODevice::canReadLine()Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
FALSEevaluated 53 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
d->plainSocketDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
d->plainSocket->canReadLine()Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
FALSEevaluated 27 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
11-89
781 return QIODevice::canReadLine();
executed 1 time by 1 test: return QIODevice::canReadLine();
Executed by:
  • tst_qsslsocket - unknown status
1
782}-
783-
784/*!-
785 \reimp-
786*/-
787void QSslSocket::close()-
788{-
789#ifdef QSSLSOCKET_DEBUG-
790 qCDebug(lcSsl) << "QSslSocket::close()";-
791#endif-
792 Q_D(QSslSocket);-
793 if (encryptedBytesToWrite() || !d->writeBuffer.isEmpty())
encryptedBytesToWrite()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 257 times by 6 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
  • tst_spdy - unknown status
!d->writeBuffer.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 257 times by 6 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
  • tst_spdy - unknown status
0-257
794 flush();
executed 3 times by 1 test: flush();
Executed by:
  • tst_qsslsocket - unknown status
3
795 if (d->plainSocket)
d->plainSocketDescription
TRUEevaluated 260 times by 6 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
  • tst_spdy - unknown status
FALSEnever evaluated
0-260
796 d->plainSocket->close();
executed 260 times by 6 tests: d->plainSocket->close();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
  • tst_spdy - unknown status
260
797 QTcpSocket::close();-
798-
799 // must be cleared, reading/writing not possible on closed socket:-
800 d->buffer.clear();-
801 d->writeBuffer.clear();-
802}
executed 260 times by 6 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
  • tst_spdy - unknown status
260
803-
804/*!-
805 \reimp-
806*/-
807bool QSslSocket::atEnd() const-
808{-
809 Q_D(const QSslSocket);-
810 if (d->mode == UnencryptedMode)
d->mode == UnencryptedModeDescription
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-11
811 return QIODevice::atEnd() && (!d->plainSocket || d->plainSocket->atEnd());
executed 11 times by 2 tests: return QIODevice::atEnd() && (!d->plainSocket || d->plainSocket->atEnd());
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
QIODevice::atEnd()Description
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
!d->plainSocketDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
d->plainSocket->atEnd()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-11
812 return QIODevice::atEnd();
never executed: return QIODevice::atEnd();
0
813}-
814-
815/*!-
816 This function writes as much as possible from the internal write buffer to-
817 the underlying network socket, without blocking. If any data was written,-
818 this function returns \c true; otherwise false is returned.-
819-
820 Call this function if you need QSslSocket to start sending buffered data-
821 immediately. The number of bytes successfully written depends on the-
822 operating system. In most cases, you do not need to call this function,-
823 because QAbstractSocket will start sending data automatically once control-
824 goes back to the event loop. In the absence of an event loop, call-
825 waitForBytesWritten() instead.-
826-
827 \sa write(), waitForBytesWritten()-
828*/-
829// Note! docs copied from QAbstractSocket::flush()-
830bool QSslSocket::flush()-
831{-
832 Q_D(QSslSocket);-
833#ifdef QSSLSOCKET_DEBUG-
834 qCDebug(lcSsl) << "QSslSocket::flush()";-
835#endif-
836 if (d->mode != UnencryptedMode)
d->mode != UnencryptedModeDescription
TRUEevaluated 1816 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
16-1816
837 // encrypt any unencrypted bytes in our buffer-
838 d->transmit();
executed 1816 times by 3 tests: d->transmit();
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
1816
839-
840 return d->plainSocket ? d->plainSocket->flush() : false;
executed 1832 times by 4 tests: return d->plainSocket ? d->plainSocket->flush() : false;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
d->plainSocketDescription
TRUEevaluated 1824 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
8-1832
841}-
842-
843/*!-
844 \since 4.4-
845-
846 Sets the size of QSslSocket's internal read buffer to be \a size bytes.-
847*/-
848void QSslSocket::setReadBufferSize(qint64 size)-
849{-
850 Q_D(QSslSocket);-
851 d->readBufferMaxSize = size;-
852-
853 if (d->plainSocket)
d->plainSocketDescription
TRUEevaluated 808 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_qtcpsocket - unknown status
FALSEnever evaluated
0-808
854 d->plainSocket->setReadBufferSize(size);
executed 808 times by 8 tests: d->plainSocket->setReadBufferSize(size);
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_qtcpsocket - unknown status
808
855}
executed 808 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_qtcpsocket - unknown status
808
856-
857/*!-
858 Aborts the current connection and resets the socket. Unlike-
859 disconnectFromHost(), this function immediately closes the socket,-
860 clearing any pending data in the write buffer.-
861-
862 \sa disconnectFromHost(), close()-
863*/-
864void QSslSocket::abort()-
865{-
866 Q_D(QSslSocket);-
867#ifdef QSSLSOCKET_DEBUG-
868 qCDebug(lcSsl) << "QSslSocket::abort()";-
869#endif-
870 if (d->plainSocket)
d->plainSocketDescription
TRUEevaluated 81 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-81
871 d->plainSocket->abort();
executed 81 times by 3 tests: d->plainSocket->abort();
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
81
872 close();-
873}
executed 81 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
81
874-
875/*!-
876 \since 4.4-
877-
878 Returns the socket's SSL configuration state. The default SSL-
879 configuration of a socket is to use the default ciphers,-
880 default CA certificates, no local private key or certificate.-
881-
882 The SSL configuration also contains fields that can change with-
883 time without notice.-
884-
885 \sa localCertificate(), peerCertificate(), peerCertificateChain(),-
886 sessionCipher(), privateKey(), ciphers(), caCertificates()-
887*/-
888QSslConfiguration QSslSocket::sslConfiguration() const-
889{-
890 Q_D(const QSslSocket);-
891-
892 // create a deep copy of our configuration-
893 QSslConfigurationPrivate *copy = new QSslConfigurationPrivate(d->configuration);-
894 copy->ref.store(0); // the QSslConfiguration constructor refs up-
895 copy->sessionCipher = d->sessionCipher();-
896 copy->sessionProtocol = d->sessionProtocol();-
897-
898 return QSslConfiguration(copy);
executed 626 times by 4 tests: return QSslConfiguration(copy);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
626
899}-
900-
901/*!-
902 \since 4.4-
903-
904 Sets the socket's SSL configuration to be the contents of \a configuration.-
905 This function sets the local certificate, the ciphers, the private key and the CA-
906 certificates to those stored in \a configuration.-
907-
908 It is not possible to set the SSL-state related fields.-
909-
910 \sa setLocalCertificate(), setPrivateKey(), setCaCertificates(), setCiphers()-
911*/-
912void QSslSocket::setSslConfiguration(const QSslConfiguration &configuration)-
913{-
914 Q_D(QSslSocket);-
915 d->configuration.localCertificateChain = configuration.localCertificateChain();-
916 d->configuration.privateKey = configuration.privateKey();-
917 d->configuration.ciphers = configuration.ciphers();-
918 d->configuration.ellipticCurves = configuration.ellipticCurves();-
919 d->configuration.caCertificates = configuration.caCertificates();-
920 d->configuration.peerVerifyDepth = configuration.peerVerifyDepth();-
921 d->configuration.peerVerifyMode = configuration.peerVerifyMode();-
922 d->configuration.protocol = configuration.protocol();-
923 d->configuration.sslOptions = configuration.d->sslOptions;-
924 d->configuration.sslSession = configuration.sessionTicket();-
925 d->configuration.sslSessionTicketLifeTimeHint = configuration.sessionTicketLifeTimeHint();-
926 d->configuration.nextAllowedProtocols = configuration.allowedNextProtocols();-
927 d->configuration.nextNegotiatedProtocol = configuration.nextNegotiatedProtocol();-
928 d->configuration.nextProtocolNegotiationStatus = configuration.nextProtocolNegotiationStatus();-
929-
930 // if the CA certificates were set explicitly (either via-
931 // QSslConfiguration::setCaCertificates() or QSslSocket::setCaCertificates(),-
932 // we cannot load the certificates on demand-
933 if (!configuration.d->allowRootCertOnDemandLoading)
!configuration...nDemandLoadingDescription
TRUEevaluated 52 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 84 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
52-84
934 d->allowRootCertOnDemandLoading = false;
executed 52 times by 2 tests: d->allowRootCertOnDemandLoading = false;
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
52
935}
executed 136 times by 4 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
136
936-
937/*!-
938 Sets the certificate chain to be presented to the peer during the-
939 SSL handshake to be \a localChain.-
940-
941 \sa QSslConfiguration::setLocalCertificateChain()-
942 \since 5.1-
943 */-
944void QSslSocket::setLocalCertificateChain(const QList<QSslCertificate> &localChain)-
945{-
946 Q_D(QSslSocket);-
947 d->configuration.localCertificateChain = localChain;-
948}
executed 21 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
21
949-
950/*!-
951 Returns the socket's local \l {QSslCertificate} {certificate} chain,-
952 or an empty list if no local certificates have been assigned.-
953-
954 \sa setLocalCertificateChain()-
955 \since 5.1-
956*/-
957QList<QSslCertificate> QSslSocket::localCertificateChain() const-
958{-
959 Q_D(const QSslSocket);-
960 return d->configuration.localCertificateChain;
never executed: return d->configuration.localCertificateChain;
0
961}-
962-
963/*!-
964 Sets the socket's local certificate to \a certificate. The local-
965 certificate is necessary if you need to confirm your identity to the-
966 peer. It is used together with the private key; if you set the local-
967 certificate, you must also set the private key.-
968-
969 The local certificate and private key are always necessary for server-
970 sockets, but are also rarely used by client sockets if the server requires-
971 the client to authenticate.-
972-
973 \sa localCertificate(), setPrivateKey()-
974*/-
975void QSslSocket::setLocalCertificate(const QSslCertificate &certificate)-
976{-
977 Q_D(QSslSocket);-
978 d->configuration.localCertificateChain = QList<QSslCertificate>();-
979 d->configuration.localCertificateChain += certificate;-
980}
executed 77 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
77
981-
982/*!-
983 \overload-
984-
985 Sets the socket's local \l {QSslCertificate} {certificate} to the-
986 first one found in file \a path, which is parsed according to the-
987 specified \a format.-
988*/-
989void QSslSocket::setLocalCertificate(const QString &path,-
990 QSsl::EncodingFormat format)-
991{-
992 QFile file(path);-
993 if (file.open(QIODevice::ReadOnly | QIODevice::Text))
file.open(QIOD...ODevice::Text)Description
TRUEevaluated 19 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEnever evaluated
0-19
994 setLocalCertificate(QSslCertificate(file.readAll(), format));
executed 19 times by 2 tests: setLocalCertificate(QSslCertificate(file.readAll(), format));
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
19
995-
996}
executed 19 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
19
997-
998/*!-
999 Returns the socket's local \l {QSslCertificate} {certificate}, or-
1000 an empty certificate if no local certificate has been assigned.-
1001-
1002 \sa setLocalCertificate(), privateKey()-
1003*/-
1004QSslCertificate QSslSocket::localCertificate() const-
1005{-
1006 Q_D(const QSslSocket);-
1007 if (d->configuration.localCertificateChain.isEmpty())
d->configurati...hain.isEmpty()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5
1008 return QSslCertificate();
executed 5 times by 1 test: return QSslCertificate();
Executed by:
  • tst_qsslsocket - unknown status
5
1009 return d->configuration.localCertificateChain[0];
executed 5 times by 1 test: return d->configuration.localCertificateChain[0];
Executed by:
  • tst_qsslsocket - unknown status
5
1010}-
1011-
1012/*!-
1013 Returns the peer's digital certificate (i.e., the immediate-
1014 certificate of the host you are connected to), or a null-
1015 certificate, if the peer has not assigned a certificate.-
1016-
1017 The peer certificate is checked automatically during the-
1018 handshake phase, so this function is normally used to fetch-
1019 the certificate for display or for connection diagnostic-
1020 purposes. It contains information about the peer, including-
1021 its host name, the certificate issuer, and the peer's public-
1022 key.-
1023-
1024 Because the peer certificate is set during the handshake phase, it-
1025 is safe to access the peer certificate from a slot connected to-
1026 the sslErrors() signal or the encrypted() signal.-
1027-
1028 If a null certificate is returned, it can mean the SSL handshake-
1029 failed, or it can mean the host you are connected to doesn't have-
1030 a certificate, or it can mean there is no connection.-
1031-
1032 If you want to check the peer's complete chain of certificates,-
1033 use peerCertificateChain() to get them all at once.-
1034-
1035 \sa peerCertificateChain()-
1036*/-
1037QSslCertificate QSslSocket::peerCertificate() const-
1038{-
1039 Q_D(const QSslSocket);-
1040 return d->configuration.peerCertificate;
executed 26 times by 1 test: return d->configuration.peerCertificate;
Executed by:
  • tst_qsslsocket - unknown status
26
1041}-
1042-
1043/*!-
1044 Returns the peer's chain of digital certificates, or an empty list-
1045 of certificates.-
1046-
1047 Peer certificates are checked automatically during the handshake-
1048 phase. This function is normally used to fetch certificates for-
1049 display, or for performing connection diagnostics. Certificates-
1050 contain information about the peer and the certificate issuers,-
1051 including host name, issuer names, and issuer public keys.-
1052-
1053 The peer certificates are set in QSslSocket during the handshake-
1054 phase, so it is safe to call this function from a slot connected-
1055 to the sslErrors() signal or the encrypted() signal.-
1056-
1057 If an empty list is returned, it can mean the SSL handshake-
1058 failed, or it can mean the host you are connected to doesn't have-
1059 a certificate, or it can mean there is no connection.-
1060-
1061 If you want to get only the peer's immediate certificate, use-
1062 peerCertificate().-
1063-
1064 \sa peerCertificate()-
1065*/-
1066QList<QSslCertificate> QSslSocket::peerCertificateChain() const-
1067{-
1068 Q_D(const QSslSocket);-
1069 return d->configuration.peerCertificateChain;
executed 26 times by 1 test: return d->configuration.peerCertificateChain;
Executed by:
  • tst_qsslsocket - unknown status
26
1070}-
1071-
1072/*!-
1073 Returns the socket's cryptographic \l {QSslCipher} {cipher}, or a-
1074 null cipher if the connection isn't encrypted. The socket's cipher-
1075 for the session is set during the handshake phase. The cipher is-
1076 used to encrypt and decrypt data transmitted through the socket.-
1077-
1078 QSslSocket also provides functions for setting the ordered list of-
1079 ciphers from which the handshake phase will eventually select the-
1080 session cipher. This ordered list must be in place before the-
1081 handshake phase begins.-
1082-
1083 \sa ciphers(), setCiphers(), setDefaultCiphers(), defaultCiphers(),-
1084 supportedCiphers()-
1085*/-
1086QSslCipher QSslSocket::sessionCipher() const-
1087{-
1088 Q_D(const QSslSocket);-
1089 return d->sessionCipher();
executed 27 times by 1 test: return d->sessionCipher();
Executed by:
  • tst_qsslsocket - unknown status
27
1090}-
1091-
1092/*!-
1093 Returns the socket's SSL/TLS protocol or UnknownProtocol if the-
1094 connection isn't encrypted. The socket's protocol for the session-
1095 is set during the handshake phase.-
1096-
1097 \sa protocol(), setProtocol()-
1098 \since 5.4-
1099*/-
1100QSsl::SslProtocol QSslSocket::sessionProtocol() const-
1101{-
1102 Q_D(const QSslSocket);-
1103 return d->sessionProtocol();
never executed: return d->sessionProtocol();
0
1104}-
1105-
1106-
1107/*!-
1108 Sets the socket's private \l {QSslKey} {key} to \a key. The-
1109 private key and the local \l {QSslCertificate} {certificate} are-
1110 used by clients and servers that must prove their identity to-
1111 SSL peers.-
1112-
1113 Both the key and the local certificate are required if you are-
1114 creating an SSL server socket. If you are creating an SSL client-
1115 socket, the key and local certificate are required if your client-
1116 must identify itself to an SSL server.-
1117-
1118 \sa privateKey(), setLocalCertificate()-
1119*/-
1120void QSslSocket::setPrivateKey(const QSslKey &key)-
1121{-
1122 Q_D(QSslSocket);-
1123 d->configuration.privateKey = key;-
1124}
executed 83 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
83
1125-
1126/*!-
1127 \overload-
1128-
1129 Reads the string in file \a fileName and decodes it using-
1130 a specified \a algorithm and encoding \a format to construct-
1131 an \l {QSslKey} {SSL key}. If the encoded key is encrypted,-
1132 \a passPhrase is used to decrypt it.-
1133-
1134 The socket's private key is set to the constructed key. The-
1135 private key and the local \l {QSslCertificate} {certificate} are-
1136 used by clients and servers that must prove their identity to SSL-
1137 peers.-
1138-
1139 Both the key and the local certificate are required if you are-
1140 creating an SSL server socket. If you are creating an SSL client-
1141 socket, the key and local certificate are required if your client-
1142 must identify itself to an SSL server.-
1143-
1144 \sa privateKey(), setLocalCertificate()-
1145*/-
1146void QSslSocket::setPrivateKey(const QString &fileName, QSsl::KeyAlgorithm algorithm,-
1147 QSsl::EncodingFormat format, const QByteArray &passPhrase)-
1148{-
1149 Q_D(QSslSocket);-
1150 QFile file(fileName);-
1151 if (file.open(QIODevice::ReadOnly)) {
file.open(QIODevice::ReadOnly)Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEnever evaluated
0-9
1152 d->configuration.privateKey = QSslKey(file.readAll(), algorithm,-
1153 format, QSsl::PrivateKey, passPhrase);-
1154 }
executed 9 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
9
1155}
executed 9 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
9
1156-
1157/*!-
1158 Returns this socket's private key.-
1159-
1160 \sa setPrivateKey(), localCertificate()-
1161*/-
1162QSslKey QSslSocket::privateKey() const-
1163{-
1164 Q_D(const QSslSocket);-
1165 return d->configuration.privateKey;
never executed: return d->configuration.privateKey;
0
1166}-
1167-
1168/*!-
1169 \deprecated-
1170-
1171 Use QSslConfiguration::ciphers() instead.-
1172-
1173 Returns this socket's current cryptographic cipher suite. This-
1174 list is used during the socket's handshake phase for choosing a-
1175 session cipher. The returned list of ciphers is ordered by-
1176 descending preference. (i.e., the first cipher in the list is the-
1177 most preferred cipher). The session cipher will be the first one-
1178 in the list that is also supported by the peer.-
1179-
1180 By default, the handshake phase can choose any of the ciphers-
1181 supported by this system's SSL libraries, which may vary from-
1182 system to system. The list of ciphers supported by this system's-
1183 SSL libraries is returned by supportedCiphers(). You can restrict-
1184 the list of ciphers used for choosing the session cipher for this-
1185 socket by calling setCiphers() with a subset of the supported-
1186 ciphers. You can revert to using the entire set by calling-
1187 setCiphers() with the list returned by supportedCiphers().-
1188-
1189 You can restrict the list of ciphers used for choosing the session-
1190 cipher for \e all sockets by calling setDefaultCiphers() with a-
1191 subset of the supported ciphers. You can revert to using the-
1192 entire set by calling setCiphers() with the list returned by-
1193 supportedCiphers().-
1194-
1195 \sa setCiphers(), defaultCiphers(), setDefaultCiphers(), supportedCiphers()-
1196*/-
1197QList<QSslCipher> QSslSocket::ciphers() const-
1198{-
1199 Q_D(const QSslSocket);-
1200 return d->configuration.ciphers;
executed 30 times by 1 test: return d->configuration.ciphers;
Executed by:
  • tst_qsslsocket - unknown status
30
1201}-
1202-
1203/*!-
1204 \deprecated-
1205-
1206 USe QSslConfiguration::setCiphers() instead.-
1207-
1208 Sets the cryptographic cipher suite for this socket to \a ciphers,-
1209 which must contain a subset of the ciphers in the list returned by-
1210 supportedCiphers().-
1211-
1212 Restricting the cipher suite must be done before the handshake-
1213 phase, where the session cipher is chosen.-
1214-
1215 \sa ciphers(), setDefaultCiphers(), supportedCiphers()-
1216*/-
1217void QSslSocket::setCiphers(const QList<QSslCipher> &ciphers)-
1218{-
1219 Q_D(QSslSocket);-
1220 d->configuration.ciphers = ciphers;-
1221}
executed 15 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
15
1222-
1223/*!-
1224 \deprecated-
1225-
1226 Use QSslConfiguration::setCiphers() instead.-
1227-
1228 Sets the cryptographic cipher suite for this socket to \a ciphers, which-
1229 is a colon-separated list of cipher suite names. The ciphers are listed in-
1230 order of preference, starting with the most preferred cipher. For example:-
1231-
1232 \snippet code/src_network_ssl_qsslsocket.cpp 4-
1233-
1234 Each cipher name in \a ciphers must be the name of a cipher in the-
1235 list returned by supportedCiphers(). Restricting the cipher suite-
1236 must be done before the handshake phase, where the session cipher-
1237 is chosen.-
1238-
1239 \sa ciphers(), setDefaultCiphers(), supportedCiphers()-
1240*/-
1241void QSslSocket::setCiphers(const QString &ciphers)-
1242{-
1243 Q_D(QSslSocket);-
1244 d->configuration.ciphers.clear();-
1245 foreach (const QString &cipherName, ciphers.split(QLatin1Char(':'), QString::SkipEmptyParts)) {-
1246 QSslCipher cipher(cipherName);-
1247 if (!cipher.isNull())
!cipher.isNull()Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
11-30
1248 d->configuration.ciphers << cipher;
executed 11 times by 1 test: d->configuration.ciphers << cipher;
Executed by:
  • tst_qsslsocket - unknown status
11
1249 }
executed 41 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
41
1250}
executed 11 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
11
1251-
1252/*!-
1253 \deprecated-
1254-
1255 Use QSslConfiguration::setCiphers() on the default QSslConfiguration instead.-
1256-
1257 Sets the default cryptographic cipher suite for all sockets in-
1258 this application to \a ciphers, which must contain a subset of the-
1259 ciphers in the list returned by supportedCiphers().-
1260-
1261 Restricting the default cipher suite only affects SSL sockets-
1262 that perform their handshake phase after the default cipher-
1263 suite has been changed.-
1264-
1265 \sa setCiphers(), defaultCiphers(), supportedCiphers()-
1266*/-
1267void QSslSocket::setDefaultCiphers(const QList<QSslCipher> &ciphers)-
1268{-
1269 QSslSocketPrivate::setDefaultCiphers(ciphers);-
1270}
executed 5 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
5
1271-
1272/*!-
1273 \deprecated-
1274-
1275 Use QSslConfiguration::ciphers() on the default QSslConfiguration instead.-
1276-
1277 Returns the default cryptographic cipher suite for all sockets in-
1278 this application. This list is used during the socket's handshake-
1279 phase when negotiating with the peer to choose a session cipher.-
1280 The list is ordered by preference (i.e., the first cipher in the-
1281 list is the most preferred cipher).-
1282-
1283 By default, the handshake phase can choose any of the ciphers-
1284 supported by this system's SSL libraries, which may vary from-
1285 system to system. The list of ciphers supported by this system's-
1286 SSL libraries is returned by supportedCiphers().-
1287-
1288 \sa supportedCiphers()-
1289*/-
1290QList<QSslCipher> QSslSocket::defaultCiphers()-
1291{-
1292 return QSslSocketPrivate::defaultCiphers();
executed 40 times by 1 test: return QSslSocketPrivate::defaultCiphers();
Executed by:
  • tst_qsslsocket - unknown status
40
1293}-
1294-
1295/*!-
1296 \deprecated-
1297-
1298 Use QSslConfiguration::supportedCiphers() instead.-
1299-
1300 Returns the list of cryptographic ciphers supported by this-
1301 system. This list is set by the system's SSL libraries and may-
1302 vary from system to system.-
1303-
1304 \sa defaultCiphers(), ciphers(), setCiphers()-
1305*/-
1306QList<QSslCipher> QSslSocket::supportedCiphers()-
1307{-
1308 return QSslSocketPrivate::supportedCiphers();
executed 20 times by 1 test: return QSslSocketPrivate::supportedCiphers();
Executed by:
  • tst_qsslsocket - unknown status
20
1309}-
1310-
1311/*!-
1312 Searches all files in the \a path for certificates encoded in the-
1313 specified \a format and adds them to this socket's CA certificate-
1314 database. \a path must be a file or a pattern matching one or more-
1315 files, as specified by \a syntax. Returns \c true if one or more-
1316 certificates are added to the socket's CA certificate database;-
1317 otherwise returns \c false.-
1318-
1319 The CA certificate database is used by the socket during the-
1320 handshake phase to validate the peer's certificate.-
1321-
1322 For more precise control, use addCaCertificate().-
1323-
1324 \sa addCaCertificate(), QSslCertificate::fromPath()-
1325*/-
1326bool QSslSocket::addCaCertificates(const QString &path, QSsl::EncodingFormat format,-
1327 QRegExp::PatternSyntax syntax)-
1328{-
1329 Q_D(QSslSocket);-
1330 QList<QSslCertificate> certs = QSslCertificate::fromPath(path, format, syntax);-
1331 if (certs.isEmpty())
certs.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
0-12
1332 return false;
never executed: return false;
0
1333-
1334 d->configuration.caCertificates += certs;-
1335 return true;
executed 12 times by 1 test: return true;
Executed by:
  • tst_qsslsocket - unknown status
12
1336}-
1337-
1338/*!-
1339 Adds the \a certificate to this socket's CA certificate database.-
1340 The CA certificate database is used by the socket during the-
1341 handshake phase to validate the peer's certificate.-
1342-
1343 To add multiple certificates, use addCaCertificates().-
1344-
1345 \sa caCertificates(), setCaCertificates()-
1346*/-
1347void QSslSocket::addCaCertificate(const QSslCertificate &certificate)-
1348{-
1349 Q_D(QSslSocket);-
1350 d->configuration.caCertificates += certificate;-
1351}
never executed: end of block
0
1352-
1353/*!-
1354 Adds the \a certificates to this socket's CA certificate database.-
1355 The CA certificate database is used by the socket during the-
1356 handshake phase to validate the peer's certificate.-
1357-
1358 For more precise control, use addCaCertificate().-
1359-
1360 \sa caCertificates(), addDefaultCaCertificate()-
1361*/-
1362void QSslSocket::addCaCertificates(const QList<QSslCertificate> &certificates)-
1363{-
1364 Q_D(QSslSocket);-
1365 d->configuration.caCertificates += certificates;-
1366}
executed 20 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
20
1367-
1368/*!-
1369 \deprecated-
1370-
1371 Use QSslConfiguration::setCaCertificates() instead.-
1372-
1373 Sets this socket's CA certificate database to be \a certificates.-
1374 The certificate database must be set prior to the SSL handshake.-
1375 The CA certificate database is used by the socket during the-
1376 handshake phase to validate the peer's certificate.-
1377-
1378 The CA certificate database can be reset to the current default CA-
1379 certificate database by calling this function with the list of CA-
1380 certificates returned by defaultCaCertificates().-
1381-
1382 \sa defaultCaCertificates()-
1383*/-
1384void QSslSocket::setCaCertificates(const QList<QSslCertificate> &certificates)-
1385{-
1386 Q_D(QSslSocket);-
1387 d->configuration.caCertificates = certificates;-
1388 d->allowRootCertOnDemandLoading = false;-
1389}
executed 38 times by 2 tests: end of block
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
38
1390-
1391/*!-
1392 \deprecated-
1393-
1394 Use QSslConfiguration::caCertificates() instead.-
1395-
1396 Returns this socket's CA certificate database. The CA certificate-
1397 database is used by the socket during the handshake phase to-
1398 validate the peer's certificate. It can be moodified prior to the-
1399 handshake with addCaCertificate(), addCaCertificates(), and-
1400 setCaCertificates().-
1401-
1402 \note On Unix, this method may return an empty list if the root-
1403 certificates are loaded on demand.-
1404-
1405 \sa addCaCertificate(), addCaCertificates(), setCaCertificates()-
1406*/-
1407QList<QSslCertificate> QSslSocket::caCertificates() const-
1408{-
1409 Q_D(const QSslSocket);-
1410 return d->configuration.caCertificates;
executed 20 times by 1 test: return d->configuration.caCertificates;
Executed by:
  • tst_qsslsocket - unknown status
20
1411}-
1412-
1413/*!-
1414 Searches all files in the \a path for certificates with the-
1415 specified \a encoding and adds them to the default CA certificate-
1416 database. \a path can be an explicit file, or it can contain-
1417 wildcards in the format specified by \a syntax. Returns \c true if-
1418 any CA certificates are added to the default database.-
1419-
1420 Each SSL socket's CA certificate database is initialized to the-
1421 default CA certificate database.-
1422-
1423 \sa defaultCaCertificates(), addCaCertificates(), addDefaultCaCertificate()-
1424*/-
1425bool QSslSocket::addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat encoding,-
1426 QRegExp::PatternSyntax syntax)-
1427{-
1428 return QSslSocketPrivate::addDefaultCaCertificates(path, encoding, syntax);
never executed: return QSslSocketPrivate::addDefaultCaCertificates(path, encoding, syntax);
0
1429}-
1430-
1431/*!-
1432 Adds \a certificate to the default CA certificate database. Each-
1433 SSL socket's CA certificate database is initialized to the default-
1434 CA certificate database.-
1435-
1436 \sa defaultCaCertificates(), addCaCertificates()-
1437*/-
1438void QSslSocket::addDefaultCaCertificate(const QSslCertificate &certificate)-
1439{-
1440 QSslSocketPrivate::addDefaultCaCertificate(certificate);-
1441}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
6
1442-
1443/*!-
1444 Adds \a certificates to the default CA certificate database. Each-
1445 SSL socket's CA certificate database is initialized to the default-
1446 CA certificate database.-
1447-
1448 \sa defaultCaCertificates(), addCaCertificates()-
1449*/-
1450void QSslSocket::addDefaultCaCertificates(const QList<QSslCertificate> &certificates)-
1451{-
1452 QSslSocketPrivate::addDefaultCaCertificates(certificates);-
1453}
never executed: end of block
0
1454-
1455/*!-
1456 \deprecated-
1457-
1458 Use QSslConfiguration::setCaCertificates() on the default QSslConfiguration instead.-
1459-
1460 Sets the default CA certificate database to \a certificates. The-
1461 default CA certificate database is originally set to your system's-
1462 default CA certificate database. You can override the default CA-
1463 certificate database with your own CA certificate database using-
1464 this function.-
1465-
1466 Each SSL socket's CA certificate database is initialized to the-
1467 default CA certificate database.-
1468-
1469 \sa addDefaultCaCertificate()-
1470*/-
1471void QSslSocket::setDefaultCaCertificates(const QList<QSslCertificate> &certificates)-
1472{-
1473 QSslSocketPrivate::setDefaultCaCertificates(certificates);-
1474}
executed 51 times by 2 tests: end of block
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
51
1475-
1476/*!-
1477 \deprecated-
1478-
1479 Use QSslConfiguration::caCertificates() on the default QSslConfiguration instead.-
1480-
1481 Returns the current default CA certificate database. This database-
1482 is originally set to your system's default CA certificate database.-
1483 If no system default database is found, an empty database will be-
1484 returned. You can override the default CA certificate database-
1485 with your own CA certificate database using setDefaultCaCertificates().-
1486-
1487 Each SSL socket's CA certificate database is initialized to the-
1488 default CA certificate database.-
1489-
1490 \note On Unix, this method may return an empty list if the root-
1491 certificates are loaded on demand.-
1492-
1493 \sa caCertificates()-
1494*/-
1495QList<QSslCertificate> QSslSocket::defaultCaCertificates()-
1496{-
1497 return QSslSocketPrivate::defaultCaCertificates();
executed 41 times by 2 tests: return QSslSocketPrivate::defaultCaCertificates();
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
41
1498}-
1499-
1500/*!-
1501 \deprecated-
1502-
1503 Use QSslConfiguration::systemDefaultCaCertificates instead.-
1504-
1505 This function provides the CA certificate database-
1506 provided by the operating system. The CA certificate database-
1507 returned by this function is used to initialize the database-
1508 returned by defaultCaCertificates(). You can replace that database-
1509 with your own with setDefaultCaCertificates().-
1510-
1511 \sa caCertificates(), defaultCaCertificates(), setDefaultCaCertificates()-
1512*/-
1513QList<QSslCertificate> QSslSocket::systemCaCertificates()-
1514{-
1515 // we are calling ensureInitialized() in the method below-
1516 return QSslSocketPrivate::systemCaCertificates();
executed 53 times by 2 tests: return QSslSocketPrivate::systemCaCertificates();
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
53
1517}-
1518-
1519/*!-
1520 Waits until the socket is connected, or \a msecs milliseconds,-
1521 whichever happens first. If the connection has been established,-
1522 this function returns \c true; otherwise it returns \c false.-
1523-
1524 \sa QAbstractSocket::waitForConnected()-
1525*/-
1526bool QSslSocket::waitForConnected(int msecs)-
1527{-
1528 Q_D(QSslSocket);-
1529 if (!d->plainSocket)
!d->plainSocketDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 196 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
5-196
1530 return false;
executed 5 times by 1 test: return false;
Executed by:
  • tst_qsslsocket - unknown status
5
1531 bool retVal = d->plainSocket->waitForConnected(msecs);-
1532 if (!retVal) {
!retValDescription
TRUEevaluated 25 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 171 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
25-171
1533 setSocketState(d->plainSocket->state());-
1534 d->setError(d->plainSocket->error(), d->plainSocket->errorString());-
1535 }
executed 25 times by 2 tests: end of block
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
25
1536 return retVal;
executed 196 times by 3 tests: return retVal;
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
196
1537}-
1538-
1539/*!-
1540 Waits until the socket has completed the SSL handshake and has-
1541 emitted encrypted(), or \a msecs milliseconds, whichever comes-
1542 first. If encrypted() has been emitted, this function returns-
1543 true; otherwise (e.g., the socket is disconnected, or the SSL-
1544 handshake fails), false is returned.-
1545-
1546 The following example waits up to one second for the socket to be-
1547 encrypted:-
1548-
1549 \snippet code/src_network_ssl_qsslsocket.cpp 5-
1550-
1551 If msecs is -1, this function will not time out.-
1552-
1553 \sa startClientEncryption(), startServerEncryption(), encrypted(), isEncrypted()-
1554*/-
1555bool QSslSocket::waitForEncrypted(int msecs)-
1556{-
1557 Q_D(QSslSocket);-
1558 if (!d->plainSocket || d->connectionEncrypted)
!d->plainSocketDescription
TRUEnever evaluated
FALSEevaluated 210 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
d->connectionEncryptedDescription
TRUEnever evaluated
FALSEevaluated 210 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
0-210
1559 return false;
never executed: return false;
0
1560 if (d->mode == UnencryptedMode && !d->autoStartHandshake)
d->mode == UnencryptedModeDescription
TRUEevaluated 156 times by 3 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 54 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
!d->autoStartHandshakeDescription
TRUEnever evaluated
FALSEevaluated 156 times by 3 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
0-156
1561 return false;
never executed: return false;
0
1562-
1563 QElapsedTimer stopWatch;-
1564 stopWatch.start();-
1565-
1566 if (d->plainSocket->state() != QAbstractSocket::ConnectedState) {
d->plainSocket...ConnectedStateDescription
TRUEevaluated 156 times by 3 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 54 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
54-156
1567 // Wait until we've entered connected state.-
1568 if (!d->plainSocket->waitForConnected(msecs))
!d->plainSocke...nnected(msecs)Description
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 148 times by 3 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
8-148
1569 return false;
executed 8 times by 2 tests: return false;
Executed by:
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
8
1570 }
executed 148 times by 3 tests: end of block
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
148
1571-
1572 while (!d->connectionEncrypted) {
!d->connectionEncryptedDescription
TRUEevaluated 469 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 137 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
137-469
1573 // Start the handshake, if this hasn't been started yet.-
1574 if (d->mode == UnencryptedMode)
d->mode == UnencryptedModeDescription
TRUEnever evaluated
FALSEevaluated 469 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
0-469
1575 startClientEncryption();
never executed: startClientEncryption();
0
1576 // Loop, waiting until the connection has been encrypted or an error-
1577 // occurs.-
1578 if (!d->plainSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed())))
!d->plainSocke...ch.elapsed()))Description
TRUEevaluated 65 times by 3 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 404 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
65-404
1579 return false;
executed 65 times by 3 tests: return false;
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
65
1580 }
executed 404 times by 5 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
404
1581 return d->connectionEncrypted;
executed 137 times by 5 tests: return d->connectionEncrypted;
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
137
1582}-
1583-
1584/*!-
1585 \reimp-
1586*/-
1587bool QSslSocket::waitForReadyRead(int msecs)-
1588{-
1589 Q_D(QSslSocket);-
1590 if (!d->plainSocket)
!d->plainSocketDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 286 times by 4 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
5-286
1591 return false;
executed 5 times by 1 test: return false;
Executed by:
  • tst_qsslsocket - unknown status
5
1592 if (d->mode == UnencryptedMode && !d->autoStartHandshake)
d->mode == UnencryptedModeDescription
TRUEevaluated 232 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qtcpsocket - unknown status
FALSEevaluated 54 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
!d->autoStartHandshakeDescription
TRUEevaluated 232 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-232
1593 return d->plainSocket->waitForReadyRead(msecs);
executed 232 times by 2 tests: return d->plainSocket->waitForReadyRead(msecs);
Executed by:
  • tst_NetworkSelfTest
  • tst_qtcpsocket - unknown status
232
1594-
1595 // This function must return true if and only if readyRead() *was* emitted.-
1596 // So we initialize "readyReadEmitted" to false and check if it was set to true.-
1597 // waitForReadyRead() could be called recursively, so we can't use the same variable-
1598 // (the inner waitForReadyRead() may fail, but the outer one still succeeded)-
1599 bool readyReadEmitted = false;-
1600 bool *previousReadyReadEmittedPointer = d->readyReadEmittedPointer;-
1601 d->readyReadEmittedPointer = &readyReadEmitted;-
1602-
1603 QElapsedTimer stopWatch;-
1604 stopWatch.start();-
1605-
1606 if (!d->connectionEncrypted) {
!d->connectionEncryptedDescription
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
3-51
1607 // Wait until we've entered encrypted mode, or until a failure occurs.-
1608 if (!waitForEncrypted(msecs)) {
!waitForEncrypted(msecs)Description
TRUEnever evaluated
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
0-3
1609 d->readyReadEmittedPointer = previousReadyReadEmittedPointer;-
1610 return false;
never executed: return false;
0
1611 }-
1612 }
executed 3 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
3
1613-
1614 if (!d->writeBuffer.isEmpty()) {
!d->writeBuffer.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 53 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
1-53
1615 // empty our cleartext write buffer first-
1616 d->transmit();-
1617 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
1
1618-
1619 // test readyReadEmitted first because either operation above-
1620 // (waitForEncrypted or transmit) may have set it-
1621 while (!readyReadEmitted &&
!readyReadEmittedDescription
TRUEevaluated 54 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 34 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
34-54
1622 d->plainSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) {
d->plainSocket...ch.elapsed()))Description
TRUEevaluated 34 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
20-34
1623 }
executed 34 times by 3 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
34
1624-
1625 d->readyReadEmittedPointer = previousReadyReadEmittedPointer;-
1626 return readyReadEmitted;
executed 54 times by 3 tests: return readyReadEmitted;
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
54
1627}-
1628-
1629/*!-
1630 \reimp-
1631*/-
1632bool QSslSocket::waitForBytesWritten(int msecs)-
1633{-
1634 Q_D(QSslSocket);-
1635 if (!d->plainSocket)
!d->plainSocketDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 2543 times by 4 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
5-2543
1636 return false;
executed 5 times by 1 test: return false;
Executed by:
  • tst_qsslsocket - unknown status
5
1637 if (d->mode == UnencryptedMode)
d->mode == UnencryptedModeDescription
TRUEevaluated 169 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qtcpsocket - unknown status
FALSEevaluated 2374 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
169-2374
1638 return d->plainSocket->waitForBytesWritten(msecs);
executed 169 times by 2 tests: return d->plainSocket->waitForBytesWritten(msecs);
Executed by:
  • tst_NetworkSelfTest
  • tst_qtcpsocket - unknown status
169
1639-
1640 QElapsedTimer stopWatch;-
1641 stopWatch.start();-
1642-
1643 if (!d->connectionEncrypted) {
!d->connectionEncryptedDescription
TRUEnever evaluated
FALSEevaluated 2374 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
0-2374
1644 // Wait until we've entered encrypted mode, or until a failure occurs.-
1645 if (!waitForEncrypted(msecs))
!waitForEncrypted(msecs)Description
TRUEnever evaluated
FALSEnever evaluated
0
1646 return false;
never executed: return false;
0
1647 }
never executed: end of block
0
1648 if (!d->writeBuffer.isEmpty()) {
!d->writeBuffer.isEmpty()Description
TRUEevaluated 2373 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
1-2373
1649 // empty our cleartext write buffer first-
1650 d->transmit();-
1651 }
executed 2373 times by 3 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
2373
1652-
1653 return d->plainSocket->waitForBytesWritten(qt_subtract_from_timeout(msecs, stopWatch.elapsed()));
executed 2374 times by 3 tests: return d->plainSocket->waitForBytesWritten(qt_subtract_from_timeout(msecs, stopWatch.elapsed()));
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
2374
1654}-
1655-
1656/*!-
1657 Waits until the socket has disconnected or \a msecs milliseconds,-
1658 whichever comes first. If the connection has been disconnected,-
1659 this function returns \c true; otherwise it returns \c false.-
1660-
1661 \sa QAbstractSocket::waitForDisconnected()-
1662*/-
1663bool QSslSocket::waitForDisconnected(int msecs)-
1664{-
1665 Q_D(QSslSocket);-
1666-
1667 // require calling connectToHost() before waitForDisconnected()-
1668 if (state() == UnconnectedState) {
state() == UnconnectedStateDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 120 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
5-120
1669 qCWarning(lcSsl, "QSslSocket::waitForDisconnected() is not allowed in UnconnectedState");
executed 5 times by 1 test: QMessageLogger(__FILE__, 1669, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::waitForDisconnected() is not allowed in UnconnectedState");
Executed by:
  • tst_qsslsocket - unknown status
qt_category_enabledDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5
1670 return false;
executed 5 times by 1 test: return false;
Executed by:
  • tst_qsslsocket - unknown status
5
1671 }-
1672-
1673 if (!d->plainSocket)
!d->plainSocketDescription
TRUEnever evaluated
FALSEevaluated 120 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
0-120
1674 return false;
never executed: return false;
0
1675 if (d->mode == UnencryptedMode)
d->mode == UnencryptedModeDescription
TRUEevaluated 80 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 40 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
40-80
1676 return d->plainSocket->waitForDisconnected(msecs);
executed 80 times by 3 tests: return d->plainSocket->waitForDisconnected(msecs);
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
80
1677-
1678 QElapsedTimer stopWatch;-
1679 stopWatch.start();-
1680-
1681 if (!d->connectionEncrypted) {
!d->connectionEncryptedDescription
TRUEnever evaluated
FALSEevaluated 40 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
0-40
1682 // Wait until we've entered encrypted mode, or until a failure occurs.-
1683 if (!waitForEncrypted(msecs))
!waitForEncrypted(msecs)Description
TRUEnever evaluated
FALSEnever evaluated
0
1684 return false;
never executed: return false;
0
1685 }
never executed: end of block
0
1686 bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed()));-
1687 if (!retVal) {
!retValDescription
TRUEnever evaluated
FALSEevaluated 40 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
0-40
1688 setSocketState(d->plainSocket->state());-
1689 d->setError(d->plainSocket->error(), d->plainSocket->errorString());-
1690 }
never executed: end of block
0
1691 return retVal;
executed 40 times by 2 tests: return retVal;
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
40
1692}-
1693-
1694/*!-
1695 Returns a list of the last SSL errors that occurred. This is the-
1696 same list as QSslSocket passes via the sslErrors() signal. If the-
1697 connection has been encrypted with no errors, this function will-
1698 return an empty list.-
1699-
1700 \sa connectToHostEncrypted()-
1701*/-
1702QList<QSslError> QSslSocket::sslErrors() const-
1703{-
1704 Q_D(const QSslSocket);-
1705 return d->sslErrors;
executed 13 times by 1 test: return d->sslErrors;
Executed by:
  • tst_qsslsocket - unknown status
13
1706}-
1707-
1708/*!-
1709 Returns \c true if this platform supports SSL; otherwise, returns-
1710 false. If the platform doesn't support SSL, the socket will fail-
1711 in the connection phase.-
1712*/-
1713bool QSslSocket::supportsSsl()-
1714{-
1715 return QSslSocketPrivate::supportsSsl();
executed 38789 times by 26 tests: return QSslSocketPrivate::supportsSsl();
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_networkselftest - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qnetworkreply - unknown status
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslkey - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qxmlinputsource - unknown status
  • ...
38789
1716}-
1717-
1718/*!-
1719 \since 5.0-
1720 Returns the version number of the SSL library in use. Note that-
1721 this is the version of the library in use at run-time not compile-
1722 time. If no SSL support is available then this will return an-
1723 undefined value.-
1724*/-
1725long QSslSocket::sslLibraryVersionNumber()-
1726{-
1727 return QSslSocketPrivate::sslLibraryVersionNumber();
executed 6 times by 1 test: return QSslSocketPrivate::sslLibraryVersionNumber();
Executed by:
  • tst_qsslsocket - unknown status
6
1728}-
1729-
1730/*!-
1731 \since 5.0-
1732 Returns the version string of the SSL library in use. Note that-
1733 this is the version of the library in use at run-time not compile-
1734 time. If no SSL support is available then this will return an empty value.-
1735*/-
1736QString QSslSocket::sslLibraryVersionString()-
1737{-
1738 return QSslSocketPrivate::sslLibraryVersionString();
executed 6 times by 1 test: return QSslSocketPrivate::sslLibraryVersionString();
Executed by:
  • tst_qsslsocket - unknown status
6
1739}-
1740-
1741/*!-
1742 \since 5.4-
1743 Returns the version number of the SSL library in use at compile-
1744 time. If no SSL support is available then this will return an-
1745 undefined value.-
1746-
1747 \sa sslLibraryVersionNumber()-
1748*/-
1749long QSslSocket::sslLibraryBuildVersionNumber()-
1750{-
1751 return QSslSocketPrivate::sslLibraryBuildVersionNumber();
never executed: return QSslSocketPrivate::sslLibraryBuildVersionNumber();
0
1752}-
1753-
1754/*!-
1755 \since 5.4-
1756 Returns the version string of the SSL library in use at compile-
1757 time. If no SSL support is available then this will return an-
1758 empty value.-
1759-
1760 \sa sslLibraryVersionString()-
1761*/-
1762QString QSslSocket::sslLibraryBuildVersionString()-
1763{-
1764 return QSslSocketPrivate::sslLibraryBuildVersionString();
never executed: return QSslSocketPrivate::sslLibraryBuildVersionString();
0
1765}-
1766-
1767/*!-
1768 Starts a delayed SSL handshake for a client connection. This-
1769 function can be called when the socket is in the \l ConnectedState-
1770 but still in the \l UnencryptedMode. If it is not yet connected,-
1771 or if it is already encrypted, this function has no effect.-
1772-
1773 Clients that implement STARTTLS functionality often make use of-
1774 delayed SSL handshakes. Most other clients can avoid calling this-
1775 function directly by using connectToHostEncrypted() instead, which-
1776 automatically performs the handshake.-
1777-
1778 \sa connectToHostEncrypted(), startServerEncryption()-
1779*/-
1780void QSslSocket::startClientEncryption()-
1781{-
1782 Q_D(QSslSocket);-
1783 if (d->mode != UnencryptedMode) {
d->mode != UnencryptedModeDescription
TRUEnever evaluated
FALSEevaluated 422 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-422
1784 qCWarning(lcSsl,
never executed: QMessageLogger( __FILE__ , 1785 , __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::startClientEncryption: cannot start handshake on non-plain connection") ;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1785 "QSslSocket::startClientEncryption: cannot start handshake on non-plain connection");
never executed: QMessageLogger( __FILE__ , 1785 , __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::startClientEncryption: cannot start handshake on non-plain connection") ;
0
1786 return;
never executed: return;
0
1787 }-
1788 if (state() != ConnectedState) {
state() != ConnectedStateDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 416 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
6-416
1789 qCWarning(lcSsl,
executed 6 times by 1 test: QMessageLogger( __FILE__ , 1790 , __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::startClientEncryption: cannot start handshake when not connected") ;
Executed by:
  • tst_qsslsocket - unknown status
qt_category_enabledDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
6
1790 "QSslSocket::startClientEncryption: cannot start handshake when not connected");
executed 6 times by 1 test: QMessageLogger( __FILE__ , 1790 , __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::startClientEncryption: cannot start handshake when not connected") ;
Executed by:
  • tst_qsslsocket - unknown status
6
1791 return;
executed 6 times by 1 test: return;
Executed by:
  • tst_qsslsocket - unknown status
6
1792 }-
1793#ifdef QSSLSOCKET_DEBUG-
1794 qCDebug(lcSsl) << "QSslSocket::startClientEncryption()";-
1795#endif-
1796 d->mode = SslClientMode;-
1797 emit modeChanged(d->mode);-
1798 d->startClientEncryption();-
1799}
executed 416 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
416
1800-
1801/*!-
1802 Starts a delayed SSL handshake for a server connection. This-
1803 function can be called when the socket is in the \l ConnectedState-
1804 but still in \l UnencryptedMode. If it is not connected or it is-
1805 already encrypted, the function has no effect.-
1806-
1807 For server sockets, calling this function is the only way to-
1808 initiate the SSL handshake. Most servers will call this function-
1809 immediately upon receiving a connection, or as a result of having-
1810 received a protocol-specific command to enter SSL mode (e.g, the-
1811 server may respond to receiving the string "STARTTLS\\r\\n" by-
1812 calling this function).-
1813-
1814 The most common way to implement an SSL server is to create a-
1815 subclass of QTcpServer and reimplement-
1816 QTcpServer::incomingConnection(). The returned socket descriptor-
1817 is then passed to QSslSocket::setSocketDescriptor().-
1818-
1819 \sa connectToHostEncrypted(), startClientEncryption()-
1820*/-
1821void QSslSocket::startServerEncryption()-
1822{-
1823 Q_D(QSslSocket);-
1824 if (d->mode != UnencryptedMode) {
d->mode != UnencryptedModeDescription
TRUEnever evaluated
FALSEevaluated 63 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
0-63
1825 qCWarning(lcSsl, "QSslSocket::startServerEncryption: cannot start handshake on non-plain connection");
never executed: QMessageLogger(__FILE__, 1825, __PRETTY_FUNCTION__, lcSsl().categoryName()).warning("QSslSocket::startServerEncryption: cannot start handshake on non-plain connection");
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1826 return;
never executed: return;
0
1827 }-
1828#ifdef QSSLSOCKET_DEBUG-
1829 qCDebug(lcSsl) << "QSslSocket::startServerEncryption()";-
1830#endif-
1831 d->mode = SslServerMode;-
1832 emit modeChanged(d->mode);-
1833 d->startServerEncryption();-
1834}
executed 63 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
63
1835-
1836/*!-
1837 This slot tells QSslSocket to ignore errors during QSslSocket's-
1838 handshake phase and continue connecting. If you want to continue-
1839 with the connection even if errors occur during the handshake-
1840 phase, then you must call this slot, either from a slot connected-
1841 to sslErrors(), or before the handshake phase. If you don't call-
1842 this slot, either in response to errors or before the handshake,-
1843 the connection will be dropped after the sslErrors() signal has-
1844 been emitted.-
1845-
1846 If there are no errors during the SSL handshake phase (i.e., the-
1847 identity of the peer is established with no problems), QSslSocket-
1848 will not emit the sslErrors() signal, and it is unnecessary to-
1849 call this function.-
1850-
1851 \warning Be sure to always let the user inspect the errors-
1852 reported by the sslErrors() signal, and only call this method-
1853 upon confirmation from the user that proceeding is ok.-
1854 If there are unexpected errors, the connection should be aborted.-
1855 Calling this method without inspecting the actual errors will-
1856 most likely pose a security risk for your application. Use it-
1857 with great care!-
1858-
1859 \sa sslErrors()-
1860*/-
1861void QSslSocket::ignoreSslErrors()-
1862{-
1863 Q_D(QSslSocket);-
1864 d->ignoreAllSslErrors = true;-
1865}
executed 164 times by 5 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
164
1866-
1867/*!-
1868 \overload-
1869 \since 4.6-
1870-
1871 This method tells QSslSocket to ignore only the errors given in \a-
1872 errors.-
1873-
1874 \note Because most SSL errors are associated with a certificate, for most-
1875 of them you must set the expected certificate this SSL error is related to.-
1876 If, for instance, you want to connect to a server that uses-
1877 a self-signed certificate, consider the following snippet:-
1878-
1879 \snippet code/src_network_ssl_qsslsocket.cpp 6-
1880-
1881 Multiple calls to this function will replace the list of errors that-
1882 were passed in previous calls.-
1883 You can clear the list of errors you want to ignore by calling this-
1884 function with an empty list.-
1885-
1886 \sa sslErrors()-
1887*/-
1888void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)-
1889{-
1890 Q_D(QSslSocket);-
1891 d->ignoreErrorsList = errors;-
1892}
executed 187 times by 4 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
187
1893-
1894/*!-
1895 \internal-
1896*/-
1897void QSslSocket::connectToHost(const QString &hostName, quint16 port, OpenMode openMode, NetworkLayerProtocol protocol)-
1898{-
1899 Q_D(QSslSocket);-
1900 d->preferredNetworkLayerProtocol = protocol;-
1901 if (!d->initialized)
!d->initializedDescription
TRUEevaluated 309 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 407 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
309-407
1902 d->init();
executed 309 times by 3 tests: d->init();
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
309
1903 d->initialized = false;-
1904-
1905#ifdef QSSLSOCKET_DEBUG-
1906 qCDebug(lcSsl) << "QSslSocket::connectToHost("-
1907 << hostName << ',' << port << ',' << openMode << ')';-
1908#endif-
1909 if (!d->plainSocket) {
!d->plainSocketDescription
TRUEevaluated 588 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_qtcpsocket - unknown status
FALSEevaluated 128 times by 4 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
128-588
1910#ifdef QSSLSOCKET_DEBUG-
1911 qCDebug(lcSsl) << "\tcreating internal plain socket";-
1912#endif-
1913 d->createPlainSocket(openMode);-
1914 }
executed 588 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_qtcpsocket - unknown status
588
1915#ifndef QT_NO_NETWORKPROXY-
1916 d->plainSocket->setProxy(proxy());-
1917#endif-
1918 QIODevice::open(openMode);-
1919 d->plainSocket->connectToHost(hostName, port, openMode, d->preferredNetworkLayerProtocol);-
1920 d->cachedSocketDescriptor = d->plainSocket->socketDescriptor();-
1921}
executed 716 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_qtcpsocket - unknown status
716
1922-
1923/*!-
1924 \internal-
1925*/-
1926void QSslSocket::disconnectFromHost()-
1927{-
1928 Q_D(QSslSocket);-
1929#ifdef QSSLSOCKET_DEBUG-
1930 qCDebug(lcSsl) << "QSslSocket::disconnectFromHost()";-
1931#endif-
1932 if (!d->plainSocket)
!d->plainSocketDescription
TRUEnever evaluated
FALSEevaluated 161 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
0-161
1933 return;
never executed: return;
0
1934 if (d->state == UnconnectedState)
d->state == UnconnectedStateDescription
TRUEnever evaluated
FALSEevaluated 161 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
0-161
1935 return;
never executed: return;
0
1936 if (d->mode == UnencryptedMode && !d->autoStartHandshake) {
d->mode == UnencryptedModeDescription
TRUEevaluated 51 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 110 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
!d->autoStartHandshakeDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
9-110
1937 d->plainSocket->disconnectFromHost();-
1938 return;
executed 42 times by 1 test: return;
Executed by:
  • tst_qtcpsocket - unknown status
42
1939 }-
1940 if (d->state <= ConnectingState) {
d->state <= ConnectingStateDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 110 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
9-110
1941 d->pendingClose = true;-
1942 return;
executed 9 times by 1 test: return;
Executed by:
  • tst_qsslsocket - unknown status
9
1943 }-
1944-
1945 // Perhaps emit closing()-
1946 if (d->state != ClosingState) {
d->state != ClosingStateDescription
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 62 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
48-62
1947 d->state = ClosingState;-
1948 emit stateChanged(d->state);-
1949 }
executed 48 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
48
1950-
1951 if (!d->writeBuffer.isEmpty()) {
!d->writeBuffer.isEmpty()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 100 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
10-100
1952 d->pendingClose = true;-
1953 return;
executed 10 times by 1 test: return;
Executed by:
  • tst_qsslsocket - unknown status
10
1954 }-
1955-
1956 if (d->mode == UnencryptedMode) {
d->mode == UnencryptedModeDescription
TRUEnever evaluated
FALSEevaluated 100 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
0-100
1957 d->plainSocket->disconnectFromHost();-
1958 } else {
never executed: end of block
0
1959 d->disconnectFromHost();-
1960 }
executed 100 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
100
1961}-
1962-
1963/*!-
1964 \reimp-
1965*/-
1966qint64 QSslSocket::readData(char *data, qint64 maxlen)-
1967{-
1968 Q_D(QSslSocket);-
1969 qint64 readBytes = 0;-
1970-
1971 if (d->mode == UnencryptedMode && !d->autoStartHandshake) {
d->mode == UnencryptedModeDescription
TRUEevaluated 5415 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 5635 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
!d->autoStartHandshakeDescription
TRUEevaluated 5415 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-5635
1972 readBytes = d->plainSocket->read(data, maxlen);-
1973#ifdef QSSLSOCKET_DEBUG-
1974 qCDebug(lcSsl) << "QSslSocket::readData(" << (void *)data << ',' << maxlen << ") =="-
1975 << readBytes;-
1976#endif-
1977 } else {
executed 5415 times by 3 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
5415
1978 // possibly trigger another transmit() to decrypt more data from the socket-
1979 if (d->plainSocket->bytesAvailable())
d->plainSocket...tesAvailable()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 5634 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
1-5634
1980 QMetaObject::invokeMethod(this, "_q_flushReadBuffer", Qt::QueuedConnection);
executed 1 time by 1 test: QMetaObject::invokeMethod(this, "_q_flushReadBuffer", Qt::QueuedConnection);
Executed by:
  • tst_QNetworkReply
1
1981 }
executed 5635 times by 5 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
5635
1982-
1983 return readBytes;
executed 11050 times by 6 tests: return readBytes;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
11050
1984}-
1985-
1986/*!-
1987 \reimp-
1988*/-
1989qint64 QSslSocket::writeData(const char *data, qint64 len)-
1990{-
1991 Q_D(QSslSocket);-
1992#ifdef QSSLSOCKET_DEBUG-
1993 qCDebug(lcSsl) << "QSslSocket::writeData(" << (void *)data << ',' << len << ')';-
1994#endif-
1995 if (d->mode == UnencryptedMode && !d->autoStartHandshake)
d->mode == UnencryptedModeDescription
TRUEevaluated 298 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 5396 times by 5 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
!d->autoStartHandshakeDescription
TRUEevaluated 291 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
7-5396
1996 return d->plainSocket->write(data, len);
executed 291 times by 3 tests: return d->plainSocket->write(data, len);
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
291
1997-
1998 char *writePtr = d->writeBuffer.reserve(len);-
1999 ::memcpy(writePtr, data, len);-
2000-
2001 // make sure we flush to the plain socket's buffer-
2002 QMetaObject::invokeMethod(this, "_q_flushWriteBuffer", Qt::QueuedConnection);-
2003-
2004 return len;
executed 5403 times by 5 tests: return len;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
5403
2005}-
2006-
2007/*!-
2008 \internal-
2009*/-
2010QSslSocketPrivate::QSslSocketPrivate()-
2011 : initialized(false)-
2012 , mode(QSslSocket::UnencryptedMode)-
2013 , autoStartHandshake(false)-
2014 , connectionEncrypted(false)-
2015 , shutdown(false)-
2016 , ignoreAllSslErrors(false)-
2017 , readyReadEmittedPointer(0)-
2018 , allowRootCertOnDemandLoading(true)-
2019 , plainSocket(0)-
2020 , paused(false)-
2021{-
2022 QSslConfigurationPrivate::deepCopyDefaultConfiguration(&configuration);-
2023}
executed 713 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_qtcpsocket - unknown status
713
2024-
2025/*!-
2026 \internal-
2027*/-
2028QSslSocketPrivate::~QSslSocketPrivate()-
2029{-
2030}-
2031-
2032/*!-
2033 \internal-
2034*/-
2035void QSslSocketPrivate::init()-
2036{-
2037 mode = QSslSocket::UnencryptedMode;-
2038 autoStartHandshake = false;-
2039 connectionEncrypted = false;-
2040 ignoreAllSslErrors = false;-
2041 shutdown = false;-
2042 pendingClose = false;-
2043-
2044 // we don't want to clear the ignoreErrorsList, so-
2045 // that it is possible setting it before connecting-
2046// ignoreErrorsList.clear();-
2047-
2048 buffer.clear();-
2049 writeBuffer.clear();-
2050 configuration.peerCertificate.clear();-
2051 configuration.peerCertificateChain.clear();-
2052}
executed 1444 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_qtcpsocket - unknown status
1444
2053-
2054/*!-
2055 \internal-
2056*/-
2057QList<QSslCipher> QSslSocketPrivate::defaultCiphers()-
2058{-
2059 QSslSocketPrivate::ensureInitialized();-
2060 QMutexLocker locker(&globalData()->mutex);-
2061 return globalData()->config->ciphers;
executed 94 times by 4 tests: return globalData()->config->ciphers;
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
94
2062}-
2063-
2064/*!-
2065 \internal-
2066*/-
2067QList<QSslCipher> QSslSocketPrivate::supportedCiphers()-
2068{-
2069 QSslSocketPrivate::ensureInitialized();-
2070 QMutexLocker locker(&globalData()->mutex);-
2071 return globalData()->supportedCiphers;
executed 61 times by 1 test: return globalData()->supportedCiphers;
Executed by:
  • tst_qsslsocket - unknown status
61
2072}-
2073-
2074/*!-
2075 \internal-
2076*/-
2077void QSslSocketPrivate::setDefaultCiphers(const QList<QSslCipher> &ciphers)-
2078{-
2079 QMutexLocker locker(&globalData()->mutex);-
2080 globalData()->config.detach();-
2081 globalData()->config->ciphers = ciphers;-
2082}
executed 20 times by 15 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
20
2083-
2084/*!-
2085 \internal-
2086*/-
2087void QSslSocketPrivate::setDefaultSupportedCiphers(const QList<QSslCipher> &ciphers)-
2088{-
2089 QMutexLocker locker(&globalData()->mutex);-
2090 globalData()->config.detach();-
2091 globalData()->supportedCiphers = ciphers;-
2092}
executed 15 times by 15 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
15
2093-
2094/*!-
2095 \internal-
2096*/-
2097QVector<QSslEllipticCurve> QSslSocketPrivate::supportedEllipticCurves()-
2098{-
2099 QSslSocketPrivate::ensureInitialized();-
2100 const QMutexLocker locker(&globalData()->mutex);-
2101 return globalData()->supportedEllipticCurves;
executed 2 times by 1 test: return globalData()->supportedEllipticCurves;
Executed by:
  • tst_qsslellipticcurve - unknown status
2
2102}-
2103-
2104/*!-
2105 \internal-
2106*/-
2107void QSslSocketPrivate::setDefaultSupportedEllipticCurves(const QVector<QSslEllipticCurve> &curves)-
2108{-
2109 const QMutexLocker locker(&globalData()->mutex);-
2110 globalData()->config.detach();-
2111 globalData()->supportedEllipticCurves = curves;-
2112}
executed 15 times by 15 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
15
2113-
2114/*!-
2115 \internal-
2116*/-
2117QList<QSslCertificate> QSslSocketPrivate::defaultCaCertificates()-
2118{-
2119 QSslSocketPrivate::ensureInitialized();-
2120 QMutexLocker locker(&globalData()->mutex);-
2121 return globalData()->config->caCertificates;
executed 42 times by 3 tests: return globalData()->config->caCertificates;
Executed by:
  • tst_QNetworkReply
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
42
2122}-
2123-
2124/*!-
2125 \internal-
2126*/-
2127void QSslSocketPrivate::setDefaultCaCertificates(const QList<QSslCertificate> &certs)-
2128{-
2129 QSslSocketPrivate::ensureInitialized();-
2130 QMutexLocker locker(&globalData()->mutex);-
2131 globalData()->config.detach();-
2132 globalData()->config->caCertificates = certs;-
2133 // when the certificates are set explicitly, we do not want to-
2134 // load the system certificates on demand-
2135 s_loadRootCertsOnDemand = false;-
2136}
executed 52 times by 3 tests: end of block
Executed by:
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
52
2137-
2138/*!-
2139 \internal-
2140*/-
2141bool QSslSocketPrivate::addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat format,-
2142 QRegExp::PatternSyntax syntax)-
2143{-
2144 QSslSocketPrivate::ensureInitialized();-
2145 QList<QSslCertificate> certs = QSslCertificate::fromPath(path, format, syntax);-
2146 if (certs.isEmpty())
certs.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2147 return false;
never executed: return false;
0
2148-
2149 QMutexLocker locker(&globalData()->mutex);-
2150 globalData()->config.detach();-
2151 globalData()->config->caCertificates += certs;-
2152 return true;
never executed: return true;
0
2153}-
2154-
2155/*!-
2156 \internal-
2157*/-
2158void QSslSocketPrivate::addDefaultCaCertificate(const QSslCertificate &cert)-
2159{-
2160 QSslSocketPrivate::ensureInitialized();-
2161 QMutexLocker locker(&globalData()->mutex);-
2162 globalData()->config.detach();-
2163 globalData()->config->caCertificates += cert;-
2164}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
6
2165-
2166/*!-
2167 \internal-
2168*/-
2169void QSslSocketPrivate::addDefaultCaCertificates(const QList<QSslCertificate> &certs)-
2170{-
2171 QSslSocketPrivate::ensureInitialized();-
2172 QMutexLocker locker(&globalData()->mutex);-
2173 globalData()->config.detach();-
2174 globalData()->config->caCertificates += certs;-
2175}
never executed: end of block
0
2176-
2177/*!-
2178 \internal-
2179*/-
2180QSslConfiguration QSslConfigurationPrivate::defaultConfiguration()-
2181{-
2182 QSslSocketPrivate::ensureInitialized();-
2183 QMutexLocker locker(&globalData()->mutex);-
2184 return QSslConfiguration(globalData()->config.data());
executed 1001 times by 11 tests: return QSslConfiguration(globalData()->config.data());
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
1001
2185}-
2186-
2187/*!-
2188 \internal-
2189*/-
2190void QSslConfigurationPrivate::setDefaultConfiguration(const QSslConfiguration &configuration)-
2191{-
2192 QSslSocketPrivate::ensureInitialized();-
2193 QMutexLocker locker(&globalData()->mutex);-
2194 if (globalData()->config == configuration.d)
globalData()->...onfiguration.dDescription
TRUEnever evaluated
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
0-16
2195 return; // nothing to do
never executed: return;
0
2196-
2197 globalData()->config = const_cast<QSslConfigurationPrivate*>(configuration.d.constData());-
2198}
executed 16 times by 2 tests: end of block
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
16
2199-
2200/*!-
2201 \internal-
2202*/-
2203void QSslConfigurationPrivate::deepCopyDefaultConfiguration(QSslConfigurationPrivate *ptr)-
2204{-
2205 QSslSocketPrivate::ensureInitialized();-
2206 QMutexLocker locker(&globalData()->mutex);-
2207 const QSslConfigurationPrivate *global = globalData()->config.constData();-
2208-
2209 if (!global)
!globalDescription
TRUEnever evaluated
FALSEevaluated 713 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_qtcpsocket - unknown status
0-713
2210 return;
never executed: return;
0
2211-
2212 ptr->ref.store(1);-
2213 ptr->peerCertificate = global->peerCertificate;-
2214 ptr->peerCertificateChain = global->peerCertificateChain;-
2215 ptr->localCertificateChain = global->localCertificateChain;-
2216 ptr->privateKey = global->privateKey;-
2217 ptr->sessionCipher = global->sessionCipher;-
2218 ptr->sessionProtocol = global->sessionProtocol;-
2219 ptr->ciphers = global->ciphers;-
2220 ptr->caCertificates = global->caCertificates;-
2221 ptr->protocol = global->protocol;-
2222 ptr->peerVerifyMode = global->peerVerifyMode;-
2223 ptr->peerVerifyDepth = global->peerVerifyDepth;-
2224 ptr->sslOptions = global->sslOptions;-
2225 ptr->ellipticCurves = global->ellipticCurves;-
2226}
executed 713 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_qtcpsocket - unknown status
713
2227-
2228/*!-
2229 \internal-
2230*/-
2231void QSslSocketPrivate::createPlainSocket(QIODevice::OpenMode openMode)-
2232{-
2233 Q_Q(QSslSocket);-
2234 q->setOpenMode(openMode); // <- from QIODevice-
2235 q->setSocketState(QAbstractSocket::UnconnectedState);-
2236 q->setSocketError(QAbstractSocket::UnknownSocketError);-
2237 q->setLocalPort(0);-
2238 q->setLocalAddress(QHostAddress());-
2239 q->setPeerPort(0);-
2240 q->setPeerAddress(QHostAddress());-
2241 q->setPeerName(QString());-
2242-
2243 plainSocket = new QTcpSocket(q);-
2244#ifndef QT_NO_BEARERMANAGEMENT-
2245 //copy network session down to the plain socket (if it has been set)-
2246 plainSocket->setProperty("_q_networksession", q->property("_q_networksession"));-
2247#endif-
2248 q->connect(plainSocket, SIGNAL(connected()),-
2249 q, SLOT(_q_connectedSlot()),-
2250 Qt::DirectConnection);-
2251 q->connect(plainSocket, SIGNAL(hostFound()),-
2252 q, SLOT(_q_hostFoundSlot()),-
2253 Qt::DirectConnection);-
2254 q->connect(plainSocket, SIGNAL(disconnected()),-
2255 q, SLOT(_q_disconnectedSlot()),-
2256 Qt::DirectConnection);-
2257 q->connect(plainSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),-
2258 q, SLOT(_q_stateChangedSlot(QAbstractSocket::SocketState)),-
2259 Qt::DirectConnection);-
2260 q->connect(plainSocket, SIGNAL(error(QAbstractSocket::SocketError)),-
2261 q, SLOT(_q_errorSlot(QAbstractSocket::SocketError)),-
2262 Qt::DirectConnection);-
2263 q->connect(plainSocket, SIGNAL(readyRead()),-
2264 q, SLOT(_q_readyReadSlot()),-
2265 Qt::DirectConnection);-
2266 q->connect(plainSocket, SIGNAL(bytesWritten(qint64)),-
2267 q, SLOT(_q_bytesWrittenSlot(qint64)),-
2268 Qt::DirectConnection);-
2269#ifndef QT_NO_NETWORKPROXY-
2270 q->connect(plainSocket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),-
2271 q, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));-
2272#endif-
2273-
2274 buffer.clear();-
2275 writeBuffer.clear();-
2276 connectionEncrypted = false;-
2277 configuration.peerCertificate.clear();-
2278 configuration.peerCertificateChain.clear();-
2279 mode = QSslSocket::UnencryptedMode;-
2280 q->setReadBufferSize(readBufferMaxSize);-
2281}
executed 670 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_qtcpsocket - unknown status
670
2282-
2283void QSslSocketPrivate::pauseSocketNotifiers(QSslSocket *socket)-
2284{-
2285 if (!socket->d_func()->plainSocket)
!socket->d_func()->plainSocketDescription
TRUEnever evaluated
FALSEevaluated 138 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
0-138
2286 return;
never executed: return;
0
2287 QAbstractSocketPrivate::pauseSocketNotifiers(socket->d_func()->plainSocket);-
2288}
executed 138 times by 4 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
138
2289-
2290void QSslSocketPrivate::resumeSocketNotifiers(QSslSocket *socket)-
2291{-
2292 if (!socket->d_func()->plainSocket)
!socket->d_func()->plainSocketDescription
TRUEnever evaluated
FALSEevaluated 118 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
0-118
2293 return;
never executed: return;
0
2294 QAbstractSocketPrivate::resumeSocketNotifiers(socket->d_func()->plainSocket);-
2295}
executed 118 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
118
2296-
2297bool QSslSocketPrivate::isPaused() const-
2298{-
2299 return paused;
never executed: return paused;
0
2300}-
2301-
2302bool QSslSocketPrivate::bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode)-
2303{-
2304 // this function is called from QAbstractSocket::bind-
2305 if (!initialized)
!initializedDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-15
2306 init();
executed 15 times by 1 test: init();
Executed by:
  • tst_qtcpsocket - unknown status
15
2307 initialized = false;-
2308-
2309#ifdef QSSLSOCKET_DEBUG-
2310 qCDebug(lcSsl) << "QSslSocket::bind(" << address << ',' << port << ',' << mode << ')';-
2311#endif-
2312 if (!plainSocket) {
!plainSocketDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-15
2313#ifdef QSSLSOCKET_DEBUG-
2314 qCDebug(lcSsl) << "\tcreating internal plain socket";-
2315#endif-
2316 createPlainSocket(QIODevice::ReadWrite);-
2317 }
executed 15 times by 1 test: end of block
Executed by:
  • tst_qtcpsocket - unknown status
15
2318 bool ret = plainSocket->bind(address, port, mode);-
2319 localPort = plainSocket->localPort();-
2320 localAddress = plainSocket->localAddress();-
2321 cachedSocketDescriptor = plainSocket->socketDescriptor();-
2322 return ret;
executed 15 times by 1 test: return ret;
Executed by:
  • tst_qtcpsocket - unknown status
15
2323}-
2324-
2325/*!-
2326 \internal-
2327*/-
2328void QSslSocketPrivate::_q_connectedSlot()-
2329{-
2330 Q_Q(QSslSocket);-
2331 q->setLocalPort(plainSocket->localPort());-
2332 q->setLocalAddress(plainSocket->localAddress());-
2333 q->setPeerPort(plainSocket->peerPort());-
2334 q->setPeerAddress(plainSocket->peerAddress());-
2335 q->setPeerName(plainSocket->peerName());-
2336 cachedSocketDescriptor = plainSocket->socketDescriptor();-
2337-
2338#ifdef QSSLSOCKET_DEBUG-
2339 qCDebug(lcSsl) << "QSslSocket::_q_connectedSlot()";-
2340 qCDebug(lcSsl) << "\tstate =" << q->state();-
2341 qCDebug(lcSsl) << "\tpeer =" << q->peerName() << q->peerAddress() << q->peerPort();-
2342 qCDebug(lcSsl) << "\tlocal =" << QHostInfo::fromName(q->localAddress().toString()).hostName()-
2343 << q->localAddress() << q->localPort();-
2344#endif-
2345-
2346 if (autoStartHandshake)
autoStartHandshakeDescription
TRUEevaluated 373 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
FALSEevaluated 265 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
265-373
2347 q->startClientEncryption();
executed 373 times by 6 tests: q->startClientEncryption();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
373
2348-
2349 emit q->connected();-
2350-
2351 if (pendingClose && !autoStartHandshake) {
pendingCloseDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 629 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_qtcpsocket - unknown status
!autoStartHandshakeDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
0-629
2352 pendingClose = false;-
2353 q->disconnectFromHost();-
2354 }
never executed: end of block
0
2355}
executed 638 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_qtcpsocket - unknown status
638
2356-
2357/*!-
2358 \internal-
2359*/-
2360void QSslSocketPrivate::_q_hostFoundSlot()-
2361{-
2362 Q_Q(QSslSocket);-
2363#ifdef QSSLSOCKET_DEBUG-
2364 qCDebug(lcSsl) << "QSslSocket::_q_hostFoundSlot()";-
2365 qCDebug(lcSsl) << "\tstate =" << q->state();-
2366#endif-
2367 emit q->hostFound();-
2368}
executed 360 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_qtcpsocket - unknown status
360
2369-
2370/*!-
2371 \internal-
2372*/-
2373void QSslSocketPrivate::_q_disconnectedSlot()-
2374{-
2375 Q_Q(QSslSocket);-
2376#ifdef QSSLSOCKET_DEBUG-
2377 qCDebug(lcSsl) << "QSslSocket::_q_disconnectedSlot()";-
2378 qCDebug(lcSsl) << "\tstate =" << q->state();-
2379#endif-
2380 disconnected();-
2381 emit q->disconnected();-
2382}
executed 700 times by 9 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_qtcpsocket - unknown status
  • tst_spdy - unknown status
700
2383-
2384/*!-
2385 \internal-
2386*/-
2387void QSslSocketPrivate::_q_stateChangedSlot(QAbstractSocket::SocketState state)-
2388{-
2389 Q_Q(QSslSocket);-
2390#ifdef QSSLSOCKET_DEBUG-
2391 qCDebug(lcSsl) << "QSslSocket::_q_stateChangedSlot(" << state << ')';-
2392#endif-
2393 q->setSocketState(state);-
2394 emit q->stateChanged(state);-
2395}
executed 3304 times by 9 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_qtcpsocket - unknown status
  • tst_spdy - unknown status
3304
2396-
2397/*!-
2398 \internal-
2399*/-
2400void QSslSocketPrivate::_q_errorSlot(QAbstractSocket::SocketError error)-
2401{-
2402 Q_UNUSED(error)-
2403#ifdef QSSLSOCKET_DEBUG-
2404 Q_Q(QSslSocket);-
2405 qCDebug(lcSsl) << "QSslSocket::_q_errorSlot(" << error << ')';-
2406 qCDebug(lcSsl) << "\tstate =" << q->state();-
2407 qCDebug(lcSsl) << "\terrorString =" << q->errorString();-
2408#endif-
2409 // this moves encrypted bytes from plain socket into our buffer-
2410 if (plainSocket->bytesAvailable()) {
plainSocket->bytesAvailable()Description
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 200 times by 7 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
22-200
2411 qint64 tmpReadBufferMaxSize = readBufferMaxSize;-
2412 readBufferMaxSize = 0; // reset temporarily so the plain sockets completely drained drained-
2413 transmit();-
2414 readBufferMaxSize = tmpReadBufferMaxSize;-
2415 }
executed 22 times by 3 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
22
2416-
2417 setErrorAndEmit(plainSocket->error(), plainSocket->errorString());-
2418}
executed 222 times by 7 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
222
2419-
2420/*!-
2421 \internal-
2422*/-
2423void QSslSocketPrivate::_q_readyReadSlot()-
2424{-
2425 Q_Q(QSslSocket);-
2426#ifdef QSSLSOCKET_DEBUG-
2427 qCDebug(lcSsl) << "QSslSocket::_q_readyReadSlot() -" << plainSocket->bytesAvailable() << "bytes available";-
2428#endif-
2429 if (mode == QSslSocket::UnencryptedMode) {
mode == QSslSo...nencryptedModeDescription
TRUEevaluated 2374 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 2902 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
2374-2902
2430 if (readyReadEmittedPointer)
readyReadEmittedPointerDescription
TRUEnever evaluated
FALSEevaluated 2374 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
0-2374
2431 *readyReadEmittedPointer = true;
never executed: *readyReadEmittedPointer = true;
0
2432 emit q->readyRead();-
2433 return;
executed 2374 times by 3 tests: return;
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
2374
2434 }-
2435-
2436 transmit();-
2437}
executed 2902 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
2902
2438-
2439/*!-
2440 \internal-
2441*/-
2442void QSslSocketPrivate::_q_bytesWrittenSlot(qint64 written)-
2443{-
2444 Q_Q(QSslSocket);-
2445#ifdef QSSLSOCKET_DEBUG-
2446 qCDebug(lcSsl) << "QSslSocket::_q_bytesWrittenSlot(" << written << ')';-
2447#endif-
2448-
2449 if (mode == QSslSocket::UnencryptedMode)
mode == QSslSo...nencryptedModeDescription
TRUEevaluated 266 times by 3 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 5177 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
266-5177
2450 emit q->bytesWritten(written);
executed 266 times by 3 tests: q->bytesWritten(written);
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
266
2451 else-
2452 emit q->encryptedBytesWritten(written);
executed 5177 times by 7 tests: q->encryptedBytesWritten(written);
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
5177
2453 if (state == QAbstractSocket::ClosingState && writeBuffer.isEmpty())
state == QAbst...::ClosingStateDescription
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 5373 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_qtcpsocket - unknown status
writeBuffer.isEmpty()Description
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-5373
2454 q->disconnectFromHost();
executed 70 times by 2 tests: q->disconnectFromHost();
Executed by:
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
70
2455}
executed 5443 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_qtcpsocket - unknown status
5443
2456-
2457/*!-
2458 \internal-
2459*/-
2460void QSslSocketPrivate::_q_flushWriteBuffer()-
2461{-
2462 Q_Q(QSslSocket);-
2463 if (!writeBuffer.isEmpty())
!writeBuffer.isEmpty()Description
TRUEevaluated 1815 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
FALSEevaluated 1199 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
1199-1815
2464 q->flush();
executed 1815 times by 3 tests: q->flush();
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
1815
2465}
executed 3014 times by 4 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
3014
2466-
2467/*!-
2468 \internal-
2469*/-
2470void QSslSocketPrivate::_q_flushReadBuffer()-
2471{-
2472 // trigger a read from the plainSocket into SSL-
2473 if (mode != QSslSocket::UnencryptedMode)
mode != QSslSo...nencryptedModeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-1
2474 transmit();
executed 1 time by 1 test: transmit();
Executed by:
  • tst_QNetworkReply
1
2475}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
2476-
2477/*!-
2478 \internal-
2479*/-
2480void QSslSocketPrivate::_q_resumeImplementation()-
2481{-
2482 if (plainSocket)
plainSocketDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEnever evaluated
0-20
2483 plainSocket->resume();
executed 20 times by 1 test: plainSocket->resume();
Executed by:
  • tst_qsslsocket - unknown status
20
2484 paused = false;-
2485 if (!connectionEncrypted) {
!connectionEncryptedDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEnever evaluated
0-20
2486 if (verifyErrorsHaveBeenIgnored()) {
verifyErrorsHaveBeenIgnored()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
10
2487 continueHandshake();-
2488 } else {
executed 10 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
10
2489 setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError, sslErrors.first().errorString());-
2490 plainSocket->disconnectFromHost();-
2491 return;
executed 10 times by 1 test: return;
Executed by:
  • tst_qsslsocket - unknown status
10
2492 }-
2493 }-
2494 transmit();-
2495}
executed 10 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
10
2496-
2497/*!-
2498 \internal-
2499*/-
2500bool QSslSocketPrivate::verifyErrorsHaveBeenIgnored()-
2501{-
2502 bool doEmitSslError;-
2503 if (!ignoreErrorsList.empty()) {
!ignoreErrorsList.empty()Description
TRUEevaluated 43 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 222 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
43-222
2504 // check whether the errors we got are all in the list of expected errors-
2505 // (applies only if the method QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)-
2506 // was called)-
2507 doEmitSslError = false;-
2508 for (int a = 0; a < sslErrors.count(); a++) {
a < sslErrors.count()Description
TRUEevaluated 43 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 27 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
27-43
2509 if (!ignoreErrorsList.contains(sslErrors.at(a))) {
!ignoreErrorsL...lErrors.at(a))Description
TRUEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
FALSEevaluated 27 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
16-27
2510 doEmitSslError = true;-
2511 break;
executed 16 times by 2 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
16
2512 }-
2513 }
executed 27 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
27
2514 } else {
executed 43 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslsocket - unknown status
43
2515 // if QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) was not called and-
2516 // we get an SSL error, emit a signal unless we ignored all errors (by calling-
2517 // QSslSocket::ignoreSslErrors() )-
2518 doEmitSslError = !ignoreAllSslErrors;-
2519 }
executed 222 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
222
2520 return !doEmitSslError;
executed 265 times by 7 tests: return !doEmitSslError;
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
265
2521}-
2522-
2523/*!-
2524 \internal-
2525*/-
2526qint64 QSslSocketPrivate::peek(char *data, qint64 maxSize)-
2527{-
2528 if (mode == QSslSocket::UnencryptedMode && !autoStartHandshake) {
mode == QSslSo...nencryptedModeDescription
TRUEevaluated 112 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
FALSEevaluated 95 times by 4 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
!autoStartHandshakeDescription
TRUEevaluated 112 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
FALSEnever evaluated
0-112
2529 //unencrypted mode - do not use QIODevice::peek, as it reads ahead data from the plain socket-
2530 //peek at data already in the QIODevice buffer (from a previous read)-
2531 qint64 r = buffer.peek(data, maxSize);-
2532 if (r == maxSize)
r == maxSizeDescription
TRUEevaluated 107 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
5-107
2533 return r;
executed 107 times by 2 tests: return r;
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
107
2534 data += r;-
2535 //peek at data in the plain socket-
2536 if (plainSocket) {
plainSocketDescription
TRUEevaluated 5 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
FALSEnever evaluated
0-5
2537 qint64 r2 = plainSocket->peek(data, maxSize - r);-
2538 if (r2 < 0)
r2 < 0Description
TRUEnever evaluated
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
0-5
2539 return (r > 0 ? r : r2);
never executed: return (r > 0 ? r : r2);
r > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2540 return r + r2;
executed 5 times by 2 tests: return r + r2;
Executed by:
  • tst_NetworkSelfTest
  • tst_qsslsocket - unknown status
5
2541 } else {-
2542 return -1;
never executed: return -1;
0
2543 }-
2544 } else {-
2545 //encrypted mode - the socket engine will read and decrypt data into the QIODevice buffer-
2546 return QTcpSocketPrivate::peek(data, maxSize);
executed 95 times by 4 tests: return QTcpSocketPrivate::peek(data, maxSize);
Executed by:
  • tst_NetworkSelfTest
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
95
2547 }-
2548}-
2549-
2550/*!-
2551 \internal-
2552*/-
2553QByteArray QSslSocketPrivate::peek(qint64 maxSize)-
2554{-
2555 if (mode == QSslSocket::UnencryptedMode && !autoStartHandshake) {
mode == QSslSo...nencryptedModeDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
!autoStartHandshakeDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEnever evaluated
0-10
2556 //unencrypted mode - do not use QIODevice::peek, as it reads ahead data from the plain socket-
2557 //peek at data already in the QIODevice buffer (from a previous read)-
2558 QByteArray ret;-
2559 ret.reserve(maxSize);-
2560 ret.resize(buffer.peek(ret.data(), maxSize));-
2561 if (ret.length() == maxSize)
ret.length() == maxSizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
1-9
2562 return ret;
executed 1 time by 1 test: return ret;
Executed by:
  • tst_qsslsocket - unknown status
1
2563 //peek at data in the plain socket-
2564 if (plainSocket)
plainSocketDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
4-5
2565 return ret + plainSocket->peek(maxSize - ret.length());
executed 4 times by 1 test: return ret + plainSocket->peek(maxSize - ret.length());
Executed by:
  • tst_qsslsocket - unknown status
4
2566 else-
2567 return QByteArray();
executed 5 times by 1 test: return QByteArray();
Executed by:
  • tst_qsslsocket - unknown status
5
2568 } else {-
2569 //encrypted mode - the socket engine will read and decrypt data into the QIODevice buffer-
2570 return QTcpSocketPrivate::peek(maxSize);
executed 2 times by 1 test: return QTcpSocketPrivate::peek(maxSize);
Executed by:
  • tst_qsslsocket - unknown status
2
2571 }-
2572}-
2573-
2574/*!-
2575 \internal-
2576*/-
2577bool QSslSocketPrivate::rootCertOnDemandLoadingSupported()-
2578{-
2579 return s_loadRootCertsOnDemand;
executed 3 times by 1 test: return s_loadRootCertsOnDemand;
Executed by:
  • tst_qsslsocket_onDemandCertificates_member - unknown status
3
2580}-
2581-
2582/*!-
2583 \internal-
2584*/-
2585QList<QByteArray> QSslSocketPrivate::unixRootCertDirectories()-
2586{-
2587 return QList<QByteArray>() << "/etc/ssl/certs/" // (K)ubuntu, OpenSUSE, Mandriva, MeeGo ...
executed 132 times by 16 tests: return QList<QByteArray>() << "/etc/ssl/certs/" << "/usr/lib/ssl/certs/" << "/usr/share/ssl/" << "/usr/local/ssl/" << "/var/ssl/certs/" << "/usr/local/ssl/certs/" << "/etc/openssl/certs/" << "/opt/openssl/certs/" << "/etc/ssl/";
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
2588 << "/usr/lib/ssl/certs/" // Gentoo, Mandrake
executed 132 times by 16 tests: return QList<QByteArray>() << "/etc/ssl/certs/" << "/usr/lib/ssl/certs/" << "/usr/share/ssl/" << "/usr/local/ssl/" << "/var/ssl/certs/" << "/usr/local/ssl/certs/" << "/etc/openssl/certs/" << "/opt/openssl/certs/" << "/etc/ssl/";
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
2589 << "/usr/share/ssl/" // Centos, Redhat, SuSE
executed 132 times by 16 tests: return QList<QByteArray>() << "/etc/ssl/certs/" << "/usr/lib/ssl/certs/" << "/usr/share/ssl/" << "/usr/local/ssl/" << "/var/ssl/certs/" << "/usr/local/ssl/certs/" << "/etc/openssl/certs/" << "/opt/openssl/certs/" << "/etc/ssl/";
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
2590 << "/usr/local/ssl/" // Normal OpenSSL Tarball
executed 132 times by 16 tests: return QList<QByteArray>() << "/etc/ssl/certs/" << "/usr/lib/ssl/certs/" << "/usr/share/ssl/" << "/usr/local/ssl/" << "/var/ssl/certs/" << "/usr/local/ssl/certs/" << "/etc/openssl/certs/" << "/opt/openssl/certs/" << "/etc/ssl/";
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
2591 << "/var/ssl/certs/" // AIX
executed 132 times by 16 tests: return QList<QByteArray>() << "/etc/ssl/certs/" << "/usr/lib/ssl/certs/" << "/usr/share/ssl/" << "/usr/local/ssl/" << "/var/ssl/certs/" << "/usr/local/ssl/certs/" << "/etc/openssl/certs/" << "/opt/openssl/certs/" << "/etc/ssl/";
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
2592 << "/usr/local/ssl/certs/" // Solaris
executed 132 times by 16 tests: return QList<QByteArray>() << "/etc/ssl/certs/" << "/usr/lib/ssl/certs/" << "/usr/share/ssl/" << "/usr/local/ssl/" << "/var/ssl/certs/" << "/usr/local/ssl/certs/" << "/etc/openssl/certs/" << "/opt/openssl/certs/" << "/etc/ssl/";
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
2593 << "/etc/openssl/certs/" // BlackBerry
executed 132 times by 16 tests: return QList<QByteArray>() << "/etc/ssl/certs/" << "/usr/lib/ssl/certs/" << "/usr/share/ssl/" << "/usr/local/ssl/" << "/var/ssl/certs/" << "/usr/local/ssl/certs/" << "/etc/openssl/certs/" << "/opt/openssl/certs/" << "/etc/ssl/";
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
2594 << "/opt/openssl/certs/" // HP-UX
executed 132 times by 16 tests: return QList<QByteArray>() << "/etc/ssl/certs/" << "/usr/lib/ssl/certs/" << "/usr/share/ssl/" << "/usr/local/ssl/" << "/var/ssl/certs/" << "/usr/local/ssl/certs/" << "/etc/openssl/certs/" << "/opt/openssl/certs/" << "/etc/ssl/";
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
2595 << "/etc/ssl/"; // OpenBSD
executed 132 times by 16 tests: return QList<QByteArray>() << "/etc/ssl/certs/" << "/usr/lib/ssl/certs/" << "/usr/share/ssl/" << "/usr/local/ssl/" << "/var/ssl/certs/" << "/usr/local/ssl/certs/" << "/etc/openssl/certs/" << "/opt/openssl/certs/" << "/etc/ssl/";
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
2596}-
2597-
2598/*!-
2599 \internal-
2600*/-
2601void QSslSocketPrivate::checkSettingSslContext(QSslSocket* socket, QSharedPointer<QSslContext> sslContext)-
2602{-
2603 if (socket->d_func()->sslContextPointer.isNull())
socket->d_func...inter.isNull()Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-25
2604 socket->d_func()->sslContextPointer = sslContext;
executed 25 times by 1 test: socket->d_func()->sslContextPointer = sslContext;
Executed by:
  • tst_QNetworkReply
25
2605}
executed 25 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
25
2606-
2607/*!-
2608 \internal-
2609*/-
2610QSharedPointer<QSslContext> QSslSocketPrivate::sslContext(QSslSocket *socket)-
2611{-
2612 return (socket) ? socket->d_func()->sslContextPointer : QSharedPointer<QSslContext>();
executed 95 times by 3 tests: return (socket) ? socket->d_func()->sslContextPointer : QSharedPointer<QSslContext>();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
(socket)Description
TRUEevaluated 95 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-95
2613}-
2614-
2615bool QSslSocketPrivate::isMatchingHostname(const QSslCertificate &cert, const QString &peerName)-
2616{-
2617 QStringList commonNameList = cert.subjectInfo(QSslCertificate::CommonName);-
2618-
2619 foreach (const QString &commonName, commonNameList) {-
2620 if (isMatchingHostname(commonName.toLower(), peerName.toLower())) {
isMatchingHost...ame.toLower())Description
TRUEevaluated 322 times by 8 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 61 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
61-322
2621 return true;
executed 322 times by 8 tests: return true;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
322
2622 }-
2623 }
executed 61 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
61
2624-
2625 foreach (const QString &altName, cert.subjectAlternativeNames().values(QSsl::DnsEntry)) {-
2626 if (isMatchingHostname(altName.toLower(), peerName.toLower())) {
isMatchingHost...ame.toLower())Description
TRUEnever evaluated
FALSEnever evaluated
0
2627 return true;
never executed: return true;
0
2628 }-
2629 }
never executed: end of block
0
2630-
2631 return false;
executed 61 times by 3 tests: return false;
Executed by:
  • tst_QNetworkReply
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
61
2632}-
2633-
2634bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hostname)-
2635{-
2636 int wildcard = cn.indexOf(QLatin1Char('*'));-
2637-
2638 // Check this is a wildcard cert, if not then just compare the strings-
2639 if (wildcard < 0)
wildcard < 0Description
TRUEevaluated 403 times by 8 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
FALSEevaluated 65 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
65-403
2640 return cn == hostname;
executed 403 times by 8 tests: return cn == hostname;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
403
2641-
2642 int firstCnDot = cn.indexOf(QLatin1Char('.'));-
2643 int secondCnDot = cn.indexOf(QLatin1Char('.'), firstCnDot+1);-
2644-
2645 // Check at least 3 components-
2646 if ((-1 == secondCnDot) || (secondCnDot+1 >= cn.length()))
(-1 == secondCnDot)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 45 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
(secondCnDot+1 >= cn.length())Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 35 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
10-45
2647 return false;
executed 30 times by 1 test: return false;
Executed by:
  • tst_qsslsocket - unknown status
30
2648-
2649 // Check * is last character of 1st component (ie. there's a following .)-
2650 if (wildcard+1 != firstCnDot)
wildcard+1 != firstCnDotDescription
TRUEnever evaluated
FALSEevaluated 35 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
0-35
2651 return false;
never executed: return false;
0
2652-
2653 // Check only one star-
2654 if (cn.lastIndexOf(QLatin1Char('*')) != wildcard)
cn.lastIndexOf...)) != wildcardDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5-30
2655 return false;
executed 5 times by 1 test: return false;
Executed by:
  • tst_qsslsocket - unknown status
5
2656-
2657 // Check characters preceding * (if any) match-
2658 if (wildcard && (hostname.leftRef(wildcard) != cn.leftRef(wildcard)))
wildcardDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
(hostname.left...Ref(wildcard))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5-15
2659 return false;
executed 5 times by 1 test: return false;
Executed by:
  • tst_qsslsocket - unknown status
5
2660-
2661 // Check characters following first . match-
2662 if (hostname.midRef(hostname.indexOf(QLatin1Char('.'))) != cn.midRef(firstCnDot))
hostname.midRe...ef(firstCnDot)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5-20
2663 return false;
executed 5 times by 1 test: return false;
Executed by:
  • tst_qsslsocket - unknown status
5
2664-
2665 // Check if the hostname is an IP address, if so then wildcards are not allowed-
2666 QHostAddress addr(hostname);-
2667 if (!addr.isNull())
!addr.isNull()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
5-15
2668 return false;
executed 5 times by 1 test: return false;
Executed by:
  • tst_qsslsocket - unknown status
5
2669-
2670 // Ok, I guess this was a wildcard CN and the hostname matches.-
2671 return true;
executed 15 times by 1 test: return true;
Executed by:
  • tst_qsslsocket - unknown status
15
2672}-
2673-
2674QT_END_NAMESPACE-
2675-
2676#include "moc_qsslsocket.cpp"-
Source codeSwitch to Preprocessed file

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