ssl/qsslsocket.cpp

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

Generated by Squish Coco Non-Commercial