Qt 4.8
Public Functions | Static Public Functions | Public Variables | Static Public Variables | Static Protected Functions | Static Protected Variables | Static Private Functions | Static Private Attributes | List of all members
QSslSocketPrivate Class Referenceabstract

#include <qsslsocket_p.h>

Inheritance diagram for QSslSocketPrivate:
QTcpSocketPrivate QAbstractSocketPrivate QIODevicePrivate QAbstractSocketEngineReceiver QObjectPrivate QObjectData QSslSocketBackendPrivate

Public Functions

void _q_bytesWrittenSlot (qint64)
 
void _q_connectedSlot ()
 
void _q_disconnectedSlot ()
 
void _q_errorSlot (QAbstractSocket::SocketError)
 
void _q_flushReadBuffer ()
 
void _q_flushWriteBuffer ()
 
void _q_hostFoundSlot ()
 
void _q_readyReadSlot ()
 
void _q_stateChangedSlot (QAbstractSocket::SocketState)
 
void createPlainSocket (QIODevice::OpenMode openMode)
 
virtual void disconnected ()=0
 
virtual void disconnectFromHost ()=0
 
void init ()
 
virtual qint64 peek (char *data, qint64 maxSize)
 
virtual QByteArray peek (qint64 maxSize)
 
 QSslSocketPrivate ()
 
virtual QSslCipher sessionCipher () const =0
 
virtual void startClientEncryption ()=0
 
virtual void startServerEncryption ()=0
 
virtual void transmit ()=0
 
virtual ~QSslSocketPrivate ()
 
- Public Functions inherited from QAbstractSocketPrivate
void _q_abortConnectionAttempt ()
 This function is called after a certain number of seconds has passed while waiting for a connection. More...
 
void _q_connectToNextAddress ()
 Called by a queued or direct connection from _q_startConnecting() or _q_testConnection(), this function takes the first address of the pending addresses list and tries to connect to it. More...
 
void _q_forceDisconnect ()
 
void _q_startConnecting (const QHostInfo &hostInfo)
 Slot connected to QHostInfo::lookupHost() in connectToHost(). More...
 
void _q_testConnection ()
 Tests if a connection has been established. More...
 
bool canReadNotification ()
 Slot connected to the read socket notifier. More...
 
bool canWriteNotification ()
 Slot connected to the write socket notifier. More...
 
void connectionNotification ()
 Slot connected to a notification of connection status change. More...
 
void exceptionNotification ()
 
void fetchConnectionParameters ()
 Sets up the internal state after the connection has succeeded. More...
 
bool flush ()
 Writes pending data in the write buffers to the socket. More...
 
bool initSocketLayer (QAbstractSocket::NetworkLayerProtocol protocol)
 Initializes the socket layer to by of type type, using the network layer protocol protocol. More...
 
void proxyAuthenticationRequired (const QNetworkProxy &proxy, QAuthenticator *authenticator)
 
 QAbstractSocketPrivate ()
 Constructs a QAbstractSocketPrivate. More...
 
bool readFromSocket ()
 Reads data from the socket layer into the read buffer. More...
 
void readNotification ()
 
void resetSocketLayer ()
 Resets the socket layer, clears the read and write buffers and deletes any socket notifiers. More...
 
void resolveProxy (const QString &hostName, quint16 port)
 Resolve the proxy to its final value. More...
 
void resolveProxy (quint16 port)
 
void setupSocketNotifiers ()
 
void startConnectingByName (const QString &host)
 Starts the connection to host, like _q_startConnecting below, but without hostname resolution. More...
 
void writeNotification ()
 
virtual ~QAbstractSocketPrivate ()
 Destructs the QAbstractSocket. More...
 
- Public Functions inherited from QIODevicePrivate
bool isSequential () const
 
virtual bool putCharHelper (char c)
 
 QIODevicePrivate ()
 
virtual ~QIODevicePrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 
- Public Functions inherited from QAbstractSocketEngineReceiver
virtual ~QAbstractSocketEngineReceiver ()
 

Static Public Functions

static void addDefaultCaCertificate (const QSslCertificate &cert)
 
static bool addDefaultCaCertificates (const QString &path, QSsl::EncodingFormat format, QRegExp::PatternSyntax syntax)
 
static void addDefaultCaCertificates (const QList< QSslCertificate > &certs)
 
static QList< QSslCertificatedefaultCaCertificates ()
 
static QList< QSslCipherdefaultCiphers ()
 
static void deinitialize ()
 
static void ensureInitialized ()
 Declared static in QSslSocketPrivate, makes sure the SSL libraries have been initialized. More...
 
static void pauseSocketNotifiers (QSslSocket *)
 
static void resetDefaultCiphers ()
 Declared static in QSslSocketPrivate, backend-dependent loading of application-wide global ciphers. More...
 
static void resumeSocketNotifiers (QSslSocket *)
 
static Q_AUTOTEST_EXPORT bool rootCertOnDemandLoadingSupported ()
 
static void setDefaultCaCertificates (const QList< QSslCertificate > &certs)
 
static void setDefaultCiphers (const QList< QSslCipher > &ciphers)
 
static void setDefaultSupportedCiphers (const QList< QSslCipher > &ciphers)
 
static QList< QSslCiphersupportedCiphers ()
 
static bool supportsSsl ()
 Does the minimum amount of initialization to determine whether SSL is supported or not. More...
 
static QList< QSslCertificatesystemCaCertificates ()
 
- Static Public Functions inherited from QAbstractSocketPrivate
static QAbstractSocketEnginegetSocketEngine (QAbstractSocket *)
 
static void pauseSocketNotifiers (QAbstractSocket *)
 
static void resumeSocketNotifiers (QAbstractSocket *)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

bool allowRootCertOnDemandLoading
 
bool autoStartHandshake
 
QSslConfigurationPrivate configuration
 
bool connectionEncrypted
 
bool ignoreAllSslErrors
 
QList< QSslErrorignoreErrorsList
 
bool initialized
 
QSslSocket::SslMode mode
 
QTcpSocketplainSocket
 
bool * readyReadEmittedPointer
 
bool shutdown
 
QList< QSslErrorsslErrors
 
QString verificationPeerName
 
- Public Variables inherited from QAbstractSocketPrivate
bool abortCalled
 
QList< QHostAddressaddresses
 
int blockingTimeout
 
int cachedSocketDescriptor
 
bool closeCalled
 
int connectTimeElapsed
 
QTimerconnectTimer
 
QTimerdisconnectTimer
 
bool emittedBytesWritten
 
bool emittedReadyRead
 
QHostAddress host
 
int hostLookupId
 
QString hostName
 
bool isBuffered
 
QHostAddress localAddress
 
quint16 localPort
 
QHostAddress peerAddress
 
QString peerName
 
quint16 peerPort
 
bool pendingClose
 
quint16 port
 
bool prePauseExceptionSocketNotifierState
 
bool prePauseReadSocketNotifierState
 
bool prePauseWriteSocketNotifierState
 
QNetworkProxy proxy
 
QNetworkProxy proxyInUse
 
QRingBuffer readBuffer
 
qint64 readBufferMaxSize
 
bool readSocketNotifierCalled
 
bool readSocketNotifierState
 
bool readSocketNotifierStateSet
 
QAbstractSocketEnginesocketEngine
 
QAbstractSocket::SocketError socketError
 
QAbstractSocket::SocketType socketType
 
QAbstractSocket::SocketState state
 
QRingBuffer writeBuffer
 
- Public Variables inherited from QIODevicePrivate
AccessMode accessMode
 
bool baseReadLineDataCalled
 
QIODevicePrivateLinearBuffer buffer
 
qint64 devicePos
 
QString errorString
 
bool firstRead
 
QIODevice::OpenMode openMode
 
qint64pDevicePos
 
qint64 pos
 
qint64pPos
 
qint64 seqDumpPos
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Static Public Variables

static PtrSecCertificateGetData ptrSecCertificateGetData = 0
 
static PtrSecTrustCopyAnchorCertificates ptrSecTrustCopyAnchorCertificates = 0
 
static PtrSecTrustSettingsCopyCertificates ptrSecTrustSettingsCopyCertificates = 0
 

Static Protected Functions

static QList< QByteArrayunixRootCertDirectories ()
 

Static Protected Variables

static bool s_loadRootCertsOnDemand = false
 

Static Private Functions

static void ensureCiphersAndCertsLoaded ()
 
static bool ensureLibraryLoaded ()
 

Static Private Attributes

static bool s_libraryLoaded = false
 
static bool s_loadedCiphersAndCerts = false
 

Additional Inherited Members

- Public Types inherited from QIODevicePrivate
enum  AccessMode { Unset, Sequential, RandomAccess }
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 98 of file qsslsocket_p.h.

Constructors and Destructors

◆ QSslSocketPrivate()

QSslSocketPrivate::QSslSocketPrivate ( )
Warning
This function is not part of the public interface.

Definition at line 1915 of file qsslsocket.cpp.

1916  : initialized(false)
1918  , autoStartHandshake(false)
1919  , connectionEncrypted(false)
1920  , shutdown(false)
1921  , ignoreAllSslErrors(false)
1924  , plainSocket(0)
1925 {
1927 }
QSslSocket::SslMode mode
Definition: qsslsocket_p.h:108
static void deepCopyDefaultConfiguration(QSslConfigurationPrivate *config)
QSslConfigurationPrivate configuration
Definition: qsslsocket_p.h:116
QTcpSocket * plainSocket
Definition: qsslsocket_p.h:153
bool * readyReadEmittedPointer
Definition: qsslsocket_p.h:114
bool allowRootCertOnDemandLoading
Definition: qsslsocket_p.h:123

◆ ~QSslSocketPrivate()

QSslSocketPrivate::~QSslSocketPrivate ( )
virtual
Warning
This function is not part of the public interface.

Definition at line 1932 of file qsslsocket.cpp.

1933 {
1934 }

Functions

◆ _q_bytesWrittenSlot()

void QSslSocketPrivate::_q_bytesWrittenSlot ( qint64  written)
Warning
This function is not part of the public interface.

Definition at line 2288 of file qsslsocket.cpp.

Referenced by createPlainSocket().

2289 {
2290  Q_Q(QSslSocket);
2291 #ifdef QSSLSOCKET_DEBUG
2292  qDebug() << "QSslSocket::_q_bytesWrittenSlot(" << written << ')';
2293 #endif
2294 
2296  emit q->bytesWritten(written);
2297  else
2298  emit q->encryptedBytesWritten(written);
2300  q->disconnectFromHost();
2301 }
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition: qsslsocket.h:67
bool isEmpty() const
QSslSocket::SslMode mode
Definition: qsslsocket_p.h:108
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qDebug(const char *,...)
QAbstractSocket::SocketState state
#define emit
Definition: qobjectdefs.h:76

◆ _q_connectedSlot()

void QSslSocketPrivate::_q_connectedSlot ( )
Warning
This function is not part of the public interface.

Definition at line 2183 of file qsslsocket.cpp.

Referenced by createPlainSocket().

2184 {
2185  Q_Q(QSslSocket);
2186  q->setLocalPort(plainSocket->localPort());
2187  q->setLocalAddress(plainSocket->localAddress());
2188  q->setPeerPort(plainSocket->peerPort());
2189  q->setPeerAddress(plainSocket->peerAddress());
2190  q->setPeerName(plainSocket->peerName());
2192 
2193 #ifdef QSSLSOCKET_DEBUG
2194  qDebug() << "QSslSocket::_q_connectedSlot()";
2195  qDebug() << "\tstate =" << q->state();
2196  qDebug() << "\tpeer =" << q->peerName() << q->peerAddress() << q->peerPort();
2197  qDebug() << "\tlocal =" << QHostInfo::fromName(q->localAddress().toString()).hostName()
2198  << q->localAddress() << q->localPort();
2199 #endif
2200  emit q->connected();
2201 
2202  if (autoStartHandshake) {
2203  q->startClientEncryption();
2204  } else if (pendingClose) {
2205  pendingClose = false;
2206  q->disconnectFromHost();
2207  }
2208 }
QString peerName() const
Returns the name of the peer as specified by connectToHost(), or an empty QString if connectToHost() ...
int socketDescriptor() const
Returns the native socket descriptor of the QAbstractSocket object if this is available; otherwise re...
QHostAddress localAddress() const
Returns the host address of the local socket if available; otherwise returns QHostAddress::Null.
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition: qsslsocket.h:67
quint16 peerPort() const
Returns the port of the connected peer if the socket is in ConnectedState; otherwise returns 0...
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qDebug(const char *,...)
#define emit
Definition: qobjectdefs.h:76
static QHostInfo fromName(const QString &name)
Looks up the IP address(es) for the given host name.
Definition: qhostinfo.cpp:273
quint16 localPort() const
Returns the host port number (in native byte order) of the local socket if available; otherwise retur...
QTcpSocket * plainSocket
Definition: qsslsocket_p.h:153
QHostAddress peerAddress() const
Returns the address of the connected peer if the socket is in ConnectedState; otherwise returns QHost...

◆ _q_disconnectedSlot()

void QSslSocketPrivate::_q_disconnectedSlot ( )
Warning
This function is not part of the public interface.

Definition at line 2226 of file qsslsocket.cpp.

Referenced by createPlainSocket().

2227 {
2228  Q_Q(QSslSocket);
2229 #ifdef QSSLSOCKET_DEBUG
2230  qDebug() << "QSslSocket::_q_disconnectedSlot()";
2231  qDebug() << "\tstate =" << q->state();
2232 #endif
2233  disconnected();
2234  emit q->disconnected();
2235 }
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition: qsslsocket.h:67
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qDebug(const char *,...)
#define emit
Definition: qobjectdefs.h:76
virtual void disconnected()=0

◆ _q_errorSlot()

void QSslSocketPrivate::_q_errorSlot ( QAbstractSocket::SocketError  error)
Warning
This function is not part of the public interface.

Definition at line 2253 of file qsslsocket.cpp.

Referenced by createPlainSocket().

2254 {
2255  Q_Q(QSslSocket);
2256 #ifdef QSSLSOCKET_DEBUG
2257  qDebug() << "QSslSocket::_q_errorSlot(" << error << ')';
2258  qDebug() << "\tstate =" << q->state();
2259  qDebug() << "\terrorString =" << q->errorString();
2260 #endif
2261  q->setSocketError(plainSocket->error());
2262  q->setErrorString(plainSocket->errorString());
2263  emit q->error(error);
2264 }
#define error(msg)
QString errorString() const
Returns a human-readable description of the last device error that occurred.
Definition: qiodevice.cpp:1671
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition: qsslsocket.h:67
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qDebug(const char *,...)
#define emit
Definition: qobjectdefs.h:76
QTcpSocket * plainSocket
Definition: qsslsocket_p.h:153
SocketError error() const
Returns the type of error that last occurred.

◆ _q_flushReadBuffer()

void QSslSocketPrivate::_q_flushReadBuffer ( )
Warning
This function is not part of the public interface.

Definition at line 2316 of file qsslsocket.cpp.

2317 {
2318  // trigger a read from the plainSocket into SSL
2320  transmit();
2321 }
QSslSocket::SslMode mode
Definition: qsslsocket_p.h:108
virtual void transmit()=0

◆ _q_flushWriteBuffer()

void QSslSocketPrivate::_q_flushWriteBuffer ( )
Warning
This function is not part of the public interface.

Definition at line 2306 of file qsslsocket.cpp.

2307 {
2308  Q_Q(QSslSocket);
2309  if (!writeBuffer.isEmpty())
2310  q->flush();
2311 }
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition: qsslsocket.h:67
bool isEmpty() const
#define Q_Q(Class)
Definition: qglobal.h:2483

◆ _q_hostFoundSlot()

void QSslSocketPrivate::_q_hostFoundSlot ( )
Warning
This function is not part of the public interface.

Definition at line 2213 of file qsslsocket.cpp.

Referenced by createPlainSocket().

2214 {
2215  Q_Q(QSslSocket);
2216 #ifdef QSSLSOCKET_DEBUG
2217  qDebug() << "QSslSocket::_q_hostFoundSlot()";
2218  qDebug() << "\tstate =" << q->state();
2219 #endif
2220  emit q->hostFound();
2221 }
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition: qsslsocket.h:67
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qDebug(const char *,...)
#define emit
Definition: qobjectdefs.h:76

◆ _q_readyReadSlot()

void QSslSocketPrivate::_q_readyReadSlot ( )
Warning
This function is not part of the public interface.

Definition at line 2269 of file qsslsocket.cpp.

Referenced by createPlainSocket().

2270 {
2271  Q_Q(QSslSocket);
2272 #ifdef QSSLSOCKET_DEBUG
2273  qDebug() << "QSslSocket::_q_readyReadSlot() -" << plainSocket->bytesAvailable() << "bytes available";
2274 #endif
2277  *readyReadEmittedPointer = true;
2278  emit q->readyRead();
2279  return;
2280  }
2281 
2282  transmit();
2283 }
qint64 bytesAvailable() const
Returns the number of incoming bytes that are waiting to be read.
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition: qsslsocket.h:67
QSslSocket::SslMode mode
Definition: qsslsocket_p.h:108
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qDebug(const char *,...)
virtual void transmit()=0
#define emit
Definition: qobjectdefs.h:76
QTcpSocket * plainSocket
Definition: qsslsocket_p.h:153
bool * readyReadEmittedPointer
Definition: qsslsocket_p.h:114

◆ _q_stateChangedSlot()

void QSslSocketPrivate::_q_stateChangedSlot ( QAbstractSocket::SocketState  state)
Warning
This function is not part of the public interface.

Definition at line 2240 of file qsslsocket.cpp.

Referenced by createPlainSocket().

2241 {
2242  Q_Q(QSslSocket);
2243 #ifdef QSSLSOCKET_DEBUG
2244  qDebug() << "QSslSocket::_q_stateChangedSlot(" << state << ')';
2245 #endif
2246  q->setSocketState(state);
2247  emit q->stateChanged(state);
2248 }
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition: qsslsocket.h:67
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qDebug(const char *,...)
QAbstractSocket::SocketState state
#define emit
Definition: qobjectdefs.h:76

◆ addDefaultCaCertificate()

void QSslSocketPrivate::addDefaultCaCertificate ( const QSslCertificate cert)
static
Warning
This function is not part of the public interface.

Definition at line 2041 of file qsslsocket.cpp.

Referenced by QSslSocket::addDefaultCaCertificate().

2042 {
2044  QMutexLocker locker(&globalData()->mutex);
2045  globalData()->config.detach();
2046  globalData()->config->caCertificates += cert;
2047 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static void ensureInitialized()
Declared static in QSslSocketPrivate, makes sure the SSL libraries have been initialized.

◆ addDefaultCaCertificates() [1/2]

bool QSslSocketPrivate::addDefaultCaCertificates ( const QString path,
QSsl::EncodingFormat  format,
QRegExp::PatternSyntax  syntax 
)
static
Warning
This function is not part of the public interface.

Definition at line 2024 of file qsslsocket.cpp.

Referenced by QSslSocket::addDefaultCaCertificates().

2026 {
2029  if (certs.isEmpty())
2030  return false;
2031 
2032  QMutexLocker locker(&globalData()->mutex);
2033  globalData()->config.detach();
2034  globalData()->config->caCertificates += certs;
2035  return true;
2036 }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static QList< QSslCertificate > fromPath(const QString &path, QSsl::EncodingFormat format=QSsl::Pem, QRegExp::PatternSyntax syntax=QRegExp::FixedString)
Searches all files in the path for certificates encoded in the specified format and returns them in a...
static void ensureInitialized()
Declared static in QSslSocketPrivate, makes sure the SSL libraries have been initialized.

◆ addDefaultCaCertificates() [2/2]

void QSslSocketPrivate::addDefaultCaCertificates ( const QList< QSslCertificate > &  certs)
static
Warning
This function is not part of the public interface.

Definition at line 2052 of file qsslsocket.cpp.

2053 {
2055  QMutexLocker locker(&globalData()->mutex);
2056  globalData()->config.detach();
2057  globalData()->config->caCertificates += certs;
2058 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static void ensureInitialized()
Declared static in QSslSocketPrivate, makes sure the SSL libraries have been initialized.

◆ createPlainSocket()

void QSslSocketPrivate::createPlainSocket ( QIODevice::OpenMode  openMode)
Warning
This function is not part of the public interface.

Definition at line 2114 of file qsslsocket.cpp.

2115 {
2116  Q_Q(QSslSocket);
2117  q->setOpenMode(openMode); // <- from QIODevice
2118  q->setSocketState(QAbstractSocket::UnconnectedState);
2119  q->setSocketError(QAbstractSocket::UnknownSocketError);
2120  q->setLocalPort(0);
2121  q->setLocalAddress(QHostAddress());
2122  q->setPeerPort(0);
2123  q->setPeerAddress(QHostAddress());
2124  q->setPeerName(QString());
2125 
2126  plainSocket = new QTcpSocket(q);
2127 #ifndef QT_NO_BEARERMANAGEMENT
2128  //copy network session down to the plain socket (if it has been set)
2129  plainSocket->setProperty("_q_networksession", q->property("_q_networksession"));
2130 #endif
2131  q->connect(plainSocket, SIGNAL(connected()),
2132  q, SLOT(_q_connectedSlot()),
2134  q->connect(plainSocket, SIGNAL(hostFound()),
2135  q, SLOT(_q_hostFoundSlot()),
2137  q->connect(plainSocket, SIGNAL(disconnected()),
2138  q, SLOT(_q_disconnectedSlot()),
2140  q->connect(plainSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
2146  q->connect(plainSocket, SIGNAL(readyRead()),
2147  q, SLOT(_q_readyReadSlot()),
2149  q->connect(plainSocket, SIGNAL(bytesWritten(qint64)),
2152 #ifndef QT_NO_NETWORKPROXY
2155 #endif
2156 
2157  readBuffer.clear();
2158  writeBuffer.clear();
2159  connectionEncrypted = false;
2163  q->setReadBufferSize(readBufferMaxSize);
2164 }
QIODevice::OpenMode openMode
Definition: qiodevice_p.h:212
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
#define error(msg)
#define SLOT(a)
Definition: qobjectdefs.h:226
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
Definition: qsslsocket.h:67
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
void _q_stateChangedSlot(QAbstractSocket::SocketState)
The QString class provides a Unicode character string.
Definition: qstring.h:83
QSslSocket::SslMode mode
Definition: qsslsocket_p.h:108
void _q_bytesWrittenSlot(qint64)
#define Q_Q(Class)
Definition: qglobal.h:2483
void _q_disconnectedSlot()
SocketState
This enum describes the different states in which a socket can be.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
The QNetworkProxy class provides a network layer proxy.
static QIntfbScreen * connected
SocketError
This enum describes the socket errors that can occur.
The QTcpSocket class provides a TCP socket.
Definition: qtcpsocket.h:56
void clear()
Removes all items from the list.
Definition: qlist.h:764
__int64 qint64
Definition: qglobal.h:942
The QAuthenticator class provides an authentication object.
QSslConfigurationPrivate configuration
Definition: qsslsocket_p.h:116
virtual void disconnected()=0
QTcpSocket * plainSocket
Definition: qsslsocket_p.h:153
void _q_errorSlot(QAbstractSocket::SocketError)
void clear()
Clears the contents of this certificate, making it a null certificate.
The QHostAddress class provides an IP address.
Definition: qhostaddress.h:70
QList< QSslCertificate > peerCertificateChain

◆ defaultCaCertificates()

QList< QSslCertificate > QSslSocketPrivate::defaultCaCertificates ( )
static
Warning
This function is not part of the public interface.

Definition at line 1999 of file qsslsocket.cpp.

Referenced by QSslSocket::defaultCaCertificates().

2000 {
2001  // ### Qt5: rename everything containing "caCertificates" to "rootCertificates" or similar
2003  QMutexLocker locker(&globalData()->mutex);
2004  return globalData()->config->caCertificates;
2005 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static void ensureInitialized()
Declared static in QSslSocketPrivate, makes sure the SSL libraries have been initialized.

◆ defaultCiphers()

QList< QSslCipher > QSslSocketPrivate::defaultCiphers ( )
static
Warning
This function is not part of the public interface.

Definition at line 1960 of file qsslsocket.cpp.

Referenced by QSslSocket::defaultCiphers(), and QSslSocketBackendPrivate::initSslContext().

1961 {
1962  QMutexLocker locker(&globalData()->mutex);
1963  return globalData()->config->ciphers;
1964 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ deinitialize()

void QSslSocketPrivate::deinitialize ( )
static
Warning
This function is not part of the public interface.

Definition at line 504 of file qsslsocket_openssl.cpp.

Referenced by QOpenSslLocks::~QOpenSslLocks().

505 {
508 }
void q_CRYPTO_set_id_callback(unsigned long(*a)())
void q_CRYPTO_set_locking_callback(void(*a)(int, int, const char *, int))

◆ disconnected()

virtual void QSslSocketPrivate::disconnected ( )
pure virtual

◆ disconnectFromHost()

virtual void QSslSocketPrivate::disconnectFromHost ( )
pure virtual

Implemented in QSslSocketBackendPrivate.

◆ ensureCiphersAndCertsLoaded()

void QSslSocketPrivate::ensureCiphersAndCertsLoaded ( )
staticprivate

Definition at line 574 of file qsslsocket_openssl.cpp.

Referenced by ensureInitialized().

575 {
576  QMutexLocker locker(openssl_locks()->initLock());
578  return;
580 
582 
583  //load symbols needed to receive certificates from system store
584 #if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
585  QLibrary securityLib("/System/Library/Frameworks/Security.framework/Versions/Current/Security");
586  if (securityLib.load()) {
587  ptrSecCertificateGetData = (PtrSecCertificateGetData) securityLib.resolve("SecCertificateGetData");
589  qWarning("could not resolve symbols in security library"); // should never happen
590 
591  ptrSecTrustSettingsCopyCertificates = (PtrSecTrustSettingsCopyCertificates) securityLib.resolve("SecTrustSettingsCopyCertificates");
592  if (!ptrSecTrustSettingsCopyCertificates) { // method was introduced in Leopard, use legacy method if it's not there
593  ptrSecTrustCopyAnchorCertificates = (PtrSecTrustCopyAnchorCertificates) securityLib.resolve("SecTrustCopyAnchorCertificates");
595  qWarning("could not resolve symbols in security library"); // should never happen
596  }
597  } else {
598  qWarning("could not load security library");
599  }
600 #elif defined(Q_OS_WIN)
601  HINSTANCE hLib = LoadLibraryW(L"Crypt32");
602  if (hLib) {
603 #if defined(Q_OS_WINCE)
604  ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, L"CertOpenStore");
605  ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, L"CertFindCertificateInStore");
606  ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, L"CertCloseStore");
607 #else
608  ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, "CertOpenSystemStoreW");
609  ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, "CertFindCertificateInStore");
610  ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, "CertCloseStore");
611 #endif
612  if (!ptrCertOpenSystemStoreW || !ptrCertFindCertificateInStore || !ptrCertCloseStore)
613  qWarning("could not resolve symbols in crypt32 library"); // should never happen
614  } else {
615  qWarning("could not load crypt32 library"); // should never happen
616  }
617 #elif defined(Q_OS_QNX)
619 #elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_MAC)
620  // check whether we can enable on-demand root-cert loading (i.e. check whether the sym links are there)
622  QStringList symLinkFilter;
623  symLinkFilter << QLatin1String("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]");
624  for (int a = 0; a < dirs.count(); ++a) {
625  QDirIterator iterator(QLatin1String(dirs.at(a)), symLinkFilter, QDir::Files);
626  if (iterator.hasNext()) {
628  break;
629  }
630  }
631 #endif
632  // if on-demand loading was not enabled, load the certs now
635 }
static PtrSecTrustCopyAnchorCertificates ptrSecTrustCopyAnchorCertificates
Definition: qsslsocket_p.h:145
static QList< QByteArray > unixRootCertDirectories()
HCERTSTORE(WINAPI * PtrCertOpenSystemStoreW)(LPCSTR, DWORD, HCRYPTPROV_LEGACY, DWORD, const void *)
Definition: qsslsocket_p.h:88
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QDirIterator class provides an iterator for directory entrylists.
Definition: qdiriterator.h:54
BOOL(WINAPI * PtrCertCloseStore)(HCERTSTORE, DWORD)
Definition: qsslsocket_p.h:93
static bool s_loadRootCertsOnDemand
Definition: qsslsocket_p.h:187
OSStatus(* PtrSecTrustCopyAnchorCertificates)(CFArrayRef *)
Definition: qsslsocket_p.h:83
static bool s_loadedCiphersAndCerts
Definition: qsslsocket_p.h:185
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static void setDefaultCaCertificates(const QList< QSslCertificate > &certs)
Q_CORE_EXPORT void qWarning(const char *,...)
OSStatus(* PtrSecTrustSettingsCopyCertificates)(int, CFArrayRef *)
Definition: qsslsocket_p.h:82
static PtrSecCertificateGetData ptrSecCertificateGetData
Definition: qsslsocket_p.h:143
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static PtrSecTrustSettingsCopyCertificates ptrSecTrustSettingsCopyCertificates
Definition: qsslsocket_p.h:144
static void resetDefaultCiphers()
Declared static in QSslSocketPrivate, backend-dependent loading of application-wide global ciphers...
static QList< QSslCertificate > systemCaCertificates()
OSStatus(* PtrSecCertificateGetData)(SecCertificateRef, CSSM_DATA_PTR)
Definition: qsslsocket_p.h:81
PCCERT_CONTEXT(WINAPI * PtrCertFindCertificateInStore)(HCERTSTORE, DWORD, DWORD, DWORD, const void *, PCCERT_CONTEXT)
Definition: qsslsocket_p.h:92
The QLibrary class loads shared libraries at runtime.
Definition: qlibrary.h:62

◆ ensureInitialized()

void QSslSocketPrivate::ensureInitialized ( )
static

◆ ensureLibraryLoaded()

bool QSslSocketPrivate::ensureLibraryLoaded ( )
staticprivate

Definition at line 525 of file qsslsocket_openssl.cpp.

Referenced by supportsSsl().

526 {
528  return false;
529 
530  // Check if the library itself needs to be initialized.
531  QMutexLocker locker(openssl_locks()->initLock());
532  if (!s_libraryLoaded) {
533  s_libraryLoaded = true;
534 
535  // Initialize OpenSSL.
538  if (q_SSL_library_init() != 1)
539  return false;
542 
543  // Initialize OpenSSL's random seed.
544  if (!q_RAND_status()) {
545  struct {
546  int msec;
547  int sec;
548  void *stack;
549  } randomish;
550 
551  int attempts = 500;
552  do {
553  if (attempts < 500) {
554 #ifdef Q_OS_UNIX
555  struct timespec ts = {0, 33333333};
556  nanosleep(&ts, 0);
557 #else
558  Sleep(3);
559 #endif
560  randomish.msec = attempts;
561  }
562  randomish.stack = (void *)&randomish;
563  randomish.msec = QTime::currentTime().msec();
564  randomish.sec = QTime::currentTime().second();
565  q_RAND_seed((const char *)&randomish, sizeof(randomish));
566  } while (!q_RAND_status() && --attempts);
567  if (!attempts)
568  return false;
569  }
570  }
571  return true;
572 }
#define q_OpenSSL_add_all_algorithms()
void q_CRYPTO_set_id_callback(unsigned long(*a)())
bool q_resolveOpenSslSymbols()
int msec() const
Returns the millisecond part (0 to 999) of the time.
Definition: qdatetime.cpp:1611
int q_SSL_library_init()
static unsigned long id_function()
void q_CRYPTO_set_locking_callback(void(*a)(int, int, const char *, int))
static void locking_function(int mode, int lockNumber, const char *, int)
int second() const
Returns the second part (0 to 59) of the time.
Definition: qdatetime.cpp:1600
int q_RAND_status()
static bool s_libraryLoaded
Definition: qsslsocket_p.h:184
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static QTime currentTime()
Returns the current time as reported by the system clock.
Definition: qdatetime.cpp:3125
void q_SSL_load_error_strings()
void q_RAND_seed(const void *a, int b)

◆ init()

void QSslSocketPrivate::init ( )
Warning
This function is not part of the public interface.

Definition at line 1939 of file qsslsocket.cpp.

1940 {
1942  autoStartHandshake = false;
1943  connectionEncrypted = false;
1944  ignoreAllSslErrors = false;
1945  shutdown = false;
1946 
1947  // we don't want to clear the ignoreErrorsList, so
1948  // that it is possible setting it before connecting
1949 // ignoreErrorsList.clear();
1950 
1951  readBuffer.clear();
1952  writeBuffer.clear();
1955 }
QSslSocket::SslMode mode
Definition: qsslsocket_p.h:108
void clear()
Removes all items from the list.
Definition: qlist.h:764
QSslConfigurationPrivate configuration
Definition: qsslsocket_p.h:116
void clear()
Clears the contents of this certificate, making it a null certificate.
QList< QSslCertificate > peerCertificateChain

◆ pauseSocketNotifiers()

void QSslSocketPrivate::pauseSocketNotifiers ( QSslSocket socket)
static

Definition at line 2166 of file qsslsocket.cpp.

Referenced by QHttpNetworkConnectionPrivate::pauseConnection().

2167 {
2168  if (!socket->d_func()->plainSocket)
2169  return;
2170  QAbstractSocketPrivate::pauseSocketNotifiers(socket->d_func()->plainSocket);
2171 }
static void pauseSocketNotifiers(QAbstractSocket *)

◆ peek() [1/2]

qint64 QSslSocketPrivate::peek ( char *  data,
qint64  maxSize 
)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QIODevicePrivate.

Definition at line 2326 of file qsslsocket.cpp.

2327 {
2329  //unencrypted mode - do not use QIODevice::peek, as it reads ahead data from the plain socket
2330  //peek at data already in the QIODevice buffer (from a previous read)
2331  qint64 r = buffer.peek(data, maxSize);
2332  if (r == maxSize)
2333  return r;
2334  data += r;
2335  //peek at data in the plain socket
2336  if (plainSocket) {
2337  qint64 r2 = plainSocket->peek(data, maxSize - r);
2338  if (r2 < 0)
2339  return (r > 0 ? r : r2);
2340  return r + r2;
2341  } else {
2342  return -1;
2343  }
2344  } else {
2345  //encrypted mode - the socket engine will read and decrypt data into the QIODevice buffer
2346  return QTcpSocketPrivate::peek(data, maxSize);
2347  }
2348 }
virtual qint64 peek(char *data, qint64 maxSize)
Definition: qiodevice.cpp:1502
QIODevicePrivateLinearBuffer buffer
Definition: qiodevice_p.h:215
QSslSocket::SslMode mode
Definition: qsslsocket_p.h:108
qint64 peek(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, without side effects (i.
Definition: qiodevice.cpp:1563
static const char * data(const QByteArray &arr)
int peek(char *target, int size)
Definition: qiodevice_p.h:113
__int64 qint64
Definition: qglobal.h:942
QTcpSocket * plainSocket
Definition: qsslsocket_p.h:153

◆ peek() [2/2]

QByteArray QSslSocketPrivate::peek ( qint64  maxSize)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QIODevicePrivate.

Definition at line 2353 of file qsslsocket.cpp.

2354 {
2356  //unencrypted mode - do not use QIODevice::peek, as it reads ahead data from the plain socket
2357  //peek at data already in the QIODevice buffer (from a previous read)
2358  QByteArray ret;
2359  ret.reserve(maxSize);
2360  ret.resize(buffer.peek(ret.data(), maxSize));
2361  if (ret.length() == maxSize)
2362  return ret;
2363  //peek at data in the plain socket
2364  if (plainSocket)
2365  return ret + plainSocket->peek(maxSize - ret.length());
2366  else
2367  return QByteArray();
2368  } else {
2369  //encrypted mode - the socket engine will read and decrypt data into the QIODevice buffer
2370  return QTcpSocketPrivate::peek(maxSize);
2371  }
2372 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
virtual qint64 peek(char *data, qint64 maxSize)
Definition: qiodevice.cpp:1502
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QIODevicePrivateLinearBuffer buffer
Definition: qiodevice_p.h:215
QSslSocket::SslMode mode
Definition: qsslsocket_p.h:108
qint64 peek(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, without side effects (i.
Definition: qiodevice.cpp:1563
int peek(char *target, int size)
Definition: qiodevice_p.h:113
int length() const
Same as size().
Definition: qbytearray.h:356
QTcpSocket * plainSocket
Definition: qsslsocket_p.h:153
void resize(int size)
Sets the size of the byte array to size bytes.
void reserve(int size)
Attempts to allocate memory for at least size bytes.
Definition: qbytearray.h:449

◆ resetDefaultCiphers()

void QSslSocketPrivate::resetDefaultCiphers ( )
static

Declared static in QSslSocketPrivate, backend-dependent loading of application-wide global ciphers.

Warning
This function is not part of the public interface.

Definition at line 664 of file qsslsocket_openssl.cpp.

Referenced by ensureCiphersAndCertsLoaded().

665 {
666  SSL_CTX *myCtx = q_SSL_CTX_new(q_SSLv23_client_method());
667  SSL *mySsl = q_SSL_new(myCtx);
668 
669  QList<QSslCipher> ciphers;
670 
671  STACK_OF(SSL_CIPHER) *supportedCiphers = q_SSL_get_ciphers(mySsl);
672  for (int i = 0; i < q_sk_SSL_CIPHER_num(supportedCiphers); ++i) {
673  if (SSL_CIPHER *cipher = q_sk_SSL_CIPHER_value(supportedCiphers, i)) {
674  if (cipher->valid) {
676  if (!ciph.isNull()) {
677  if (!ciph.name().toLower().startsWith(QLatin1String("adh")))
678  ciphers << ciph;
679  }
680  }
681  }
682  }
683 
684  q_SSL_CTX_free(myCtx);
685  q_SSL_free(mySsl);
686 
688  setDefaultCiphers(ciphers);
689 }
static void setDefaultSupportedCiphers(const QList< QSslCipher > &ciphers)
void q_SSL_CTX_free(SSL_CTX *a)
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QSslCipher class represents an SSL cryptographic cipher.
Definition: qsslcipher.h:59
static void setDefaultCiphers(const QList< QSslCipher > &ciphers)
#define q_sk_SSL_CIPHER_value(st, i)
#define q_sk_SSL_CIPHER_num(st)
SSL_METHOD * q_SSLv23_client_method()
QString name() const
Returns the name of the cipher, or an empty QString if this is a null cipher.
Definition: qsslcipher.cpp:162
SSL * q_SSL_new(SSL_CTX *a)
bool isNull() const
Returns true if this is a null cipher; otherwise returns false.
Definition: qsslcipher.cpp:151
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
void q_SSL_free(SSL *a)
static QSslCipher QSslCipher_from_SSL_CIPHER(SSL_CIPHER *cipher)
static QList< QSslCipher > supportedCiphers()
STACK_OF(SSL_CIPHER) *SSL_get_ciphers SSL *a
SSL_CTX * q_SSL_CTX_new(SSL_METHOD *a)

◆ resumeSocketNotifiers()

void QSslSocketPrivate::resumeSocketNotifiers ( QSslSocket socket)
static

Definition at line 2173 of file qsslsocket.cpp.

Referenced by QHttpNetworkConnectionPrivate::resumeConnection().

2174 {
2175  if (!socket->d_func()->plainSocket)
2176  return;
2177  QAbstractSocketPrivate::resumeSocketNotifiers(socket->d_func()->plainSocket);
2178 }
static void resumeSocketNotifiers(QAbstractSocket *)

◆ rootCertOnDemandLoadingSupported()

bool QSslSocketPrivate::rootCertOnDemandLoadingSupported ( )
static
Warning
This function is not part of the public interface.

Definition at line 2377 of file qsslsocket.cpp.

2378 {
2379  return s_loadRootCertsOnDemand;
2380 }
static bool s_loadRootCertsOnDemand
Definition: qsslsocket_p.h:187

◆ sessionCipher()

virtual QSslCipher QSslSocketPrivate::sessionCipher ( ) const
pure virtual

Implemented in QSslSocketBackendPrivate.

◆ setDefaultCaCertificates()

void QSslSocketPrivate::setDefaultCaCertificates ( const QList< QSslCertificate > &  certs)
static
Warning
This function is not part of the public interface.

Definition at line 2010 of file qsslsocket.cpp.

Referenced by ensureCiphersAndCertsLoaded(), and QSslSocket::setDefaultCaCertificates().

2011 {
2013  QMutexLocker locker(&globalData()->mutex);
2014  globalData()->config.detach();
2015  globalData()->config->caCertificates = certs;
2016  // when the certificates are set explicitly, we do not want to
2017  // load the system certificates on demand
2018  s_loadRootCertsOnDemand = false;
2019 }
static bool s_loadRootCertsOnDemand
Definition: qsslsocket_p.h:187
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static void ensureInitialized()
Declared static in QSslSocketPrivate, makes sure the SSL libraries have been initialized.

◆ setDefaultCiphers()

void QSslSocketPrivate::setDefaultCiphers ( const QList< QSslCipher > &  ciphers)
static
Warning
This function is not part of the public interface.

Definition at line 1979 of file qsslsocket.cpp.

Referenced by resetDefaultCiphers(), and QSslSocket::setDefaultCiphers().

1980 {
1981  QMutexLocker locker(&globalData()->mutex);
1982  globalData()->config.detach();
1983  globalData()->config->ciphers = ciphers;
1984 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ setDefaultSupportedCiphers()

void QSslSocketPrivate::setDefaultSupportedCiphers ( const QList< QSslCipher > &  ciphers)
static
Warning
This function is not part of the public interface.

Definition at line 1989 of file qsslsocket.cpp.

Referenced by resetDefaultCiphers().

1990 {
1991  QMutexLocker locker(&globalData()->mutex);
1992  globalData()->config.detach();
1993  globalData()->supportedCiphers = ciphers;
1994 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ startClientEncryption()

virtual void QSslSocketPrivate::startClientEncryption ( )
pure virtual

Implemented in QSslSocketBackendPrivate.

◆ startServerEncryption()

virtual void QSslSocketPrivate::startServerEncryption ( )
pure virtual

Implemented in QSslSocketBackendPrivate.

◆ supportedCiphers()

QList< QSslCipher > QSslSocketPrivate::supportedCiphers ( )
static
Warning
This function is not part of the public interface.

Definition at line 1969 of file qsslsocket.cpp.

Referenced by resetDefaultCiphers(), and QSslSocket::supportedCiphers().

1970 {
1972  QMutexLocker locker(&globalData()->mutex);
1973  return globalData()->supportedCiphers;
1974 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static void ensureInitialized()
Declared static in QSslSocketPrivate, makes sure the SSL libraries have been initialized.

◆ supportsSsl()

bool QSslSocketPrivate::supportsSsl ( )
static

Does the minimum amount of initialization to determine whether SSL is supported or not.

Warning
This function is not part of the public interface.

Definition at line 520 of file qsslsocket_openssl.cpp.

Referenced by ensureInitialized(), and QSslSocket::supportsSsl().

521 {
522  return ensureLibraryLoaded();
523 }
static bool ensureLibraryLoaded()

◆ systemCaCertificates()

QList< QSslCertificate > QSslSocketPrivate::systemCaCertificates ( )
static

Definition at line 865 of file qsslsocket_openssl.cpp.

Referenced by ensureCiphersAndCertsLoaded(), and QSslSocket::systemCaCertificates().

866 {
868 #ifdef QSSLSOCKET_DEBUG
870  timer.start();
871 #endif
872  QList<QSslCertificate> systemCerts;
873 #if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
874  CFArrayRef cfCerts;
875  OSStatus status = 1;
876 
877  OSStatus SecCertificateGetData (
878  SecCertificateRef certificate,
879  CSSM_DATA_PTR data
880  );
881 
886  status = ptrSecTrustCopyAnchorCertificates(&cfCerts);
887  if (!status) {
888  CFIndex size = CFArrayGetCount(cfCerts);
889  for (CFIndex i = 0; i < size; ++i) {
890  SecCertificateRef cfCert = (SecCertificateRef)CFArrayGetValueAtIndex(cfCerts, i);
891  CSSM_DATA data;
892  CSSM_DATA_PTR dataPtr = &data;
893  if (ptrSecCertificateGetData(cfCert, dataPtr)) {
894  qWarning("error retrieving a CA certificate from the system store");
895  } else {
896  int len = data.Length;
897  char *rawData = reinterpret_cast<char *>(data.Data);
898  QByteArray rawCert(rawData, len);
899  systemCerts.append(QSslCertificate::fromData(rawCert, QSsl::Der));
900  }
901  }
902  CFRelease(cfCerts);
903  }
904  else {
905  // no detailed error handling here
906  qWarning("could not retrieve system CA certificates");
907  }
908  }
909 #elif defined(Q_OS_WIN)
910  if (ptrCertOpenSystemStoreW && ptrCertFindCertificateInStore && ptrCertCloseStore) {
911  HCERTSTORE hSystemStore;
912 #if defined(Q_OS_WINCE)
913  hSystemStore = ptrCertOpenSystemStoreW(CERT_STORE_PROV_SYSTEM_W,
914  0,
915  0,
916  CERT_STORE_NO_CRYPT_RELEASE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,
917  L"ROOT");
918 #else
919  hSystemStore = ptrCertOpenSystemStoreW(0, L"ROOT");
920 #endif
921  if(hSystemStore) {
922  PCCERT_CONTEXT pc = NULL;
923  while(1) {
924  pc = ptrCertFindCertificateInStore( hSystemStore, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, pc);
925  if(!pc)
926  break;
927  QByteArray der((const char *)(pc->pbCertEncoded), static_cast<int>(pc->cbCertEncoded));
928  QSslCertificate cert(der, QSsl::Der);
929  systemCerts.append(cert);
930  }
931  ptrCertCloseStore(hSystemStore, 0);
932  }
933  }
934 #elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
935  QSet<QString> certFiles;
937  QDir currentDir;
938  QStringList nameFilters;
939  nameFilters << QLatin1String("*.pem") << QLatin1String("*.crt");
940  currentDir.setNameFilters(nameFilters);
941  for (int a = 0; a < directories.count(); a++) {
942  currentDir.setPath(QLatin1String(directories.at(a)));
943  QDirIterator it(currentDir);
944  while(it.hasNext()) {
945  it.next();
946  // use canonical path here to not load the same certificate twice if symlinked
947  certFiles.insert(it.fileInfo().canonicalFilePath());
948  }
949  }
950  QSetIterator<QString> it(certFiles);
951  while(it.hasNext()) {
952  systemCerts.append(QSslCertificate::fromPath(it.next()));
953  }
954  systemCerts.append(QSslCertificate::fromPath(QLatin1String("/etc/pki/tls/certs/ca-bundle.crt"), QSsl::Pem)); // Fedora, Mandriva
955  systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/local/share/certs/ca-root-nss.crt"), QSsl::Pem)); // FreeBSD's ca_root_nss
956 
957 #elif defined(Q_OS_SYMBIAN)
958  QList<QByteArray> certs;
959  QScopedPointer<CSymbianCertificateRetriever> retriever(CSymbianCertificateRetriever::NewL());
960 
961  retriever->GetCertificates(certs);
962  foreach (const QByteArray &encodedCert, certs) {
963  QSslCertificate cert(encodedCert, QSsl::Der);
964  if (!cert.isNull()) {
965 #ifdef QSSLSOCKET_DEBUG
966  qDebug() << "imported certificate: " << cert.issuerInfo(QSslCertificate::CommonName);
967 #endif
968  systemCerts.append(cert);
969  }
970  }
971 #endif
972 #ifdef QSSLSOCKET_DEBUG
973  qDebug() << "systemCaCertificates retrieval time " << timer.elapsed() << "ms";
974  qDebug() << "imported " << systemCerts.count() << " certificates";
975 #endif
976 
977  return systemCerts;
978 }
static PtrSecTrustCopyAnchorCertificates ptrSecTrustCopyAnchorCertificates
Definition: qsslsocket_p.h:145
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
#define it(className, varName)
static QList< QByteArray > unixRootCertDirectories()
void setPath(const QString &path)
Sets the path of the directory to path.
Definition: qdir.cpp:590
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
EventLoopTimerRef timer
The QDirIterator class provides an iterator for directory entrylists.
Definition: qdiriterator.h:54
#define kSecTrustSettingsDomainSystem
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:53
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
void setNameFilters(const QStringList &nameFilters)
Sets the name filters used by entryList() and entryInfoList() to the list of filters specified by nam...
Definition: qdir.cpp:966
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT void qWarning(const char *,...)
const_iterator insert(const T &value)
Definition: qset.h:179
static const char * data(const QByteArray &arr)
signed long OSStatus
Definition: qssl.h:62
static PtrSecCertificateGetData ptrSecCertificateGetData
Definition: qsslsocket_p.h:143
static PtrSecTrustSettingsCopyCertificates ptrSecTrustSettingsCopyCertificates
Definition: qsslsocket_p.h:144
Definition: qssl.h:63
static QList< QSslCertificate > fromPath(const QString &path, QSsl::EncodingFormat format=QSsl::Pem, QRegExp::PatternSyntax syntax=QRegExp::FixedString)
Searches all files in the path for certificates encoded in the specified format and returns them in a...
static void ensureInitialized()
Declared static in QSslSocketPrivate, makes sure the SSL libraries have been initialized.
The QSslCertificate class provides a convenient API for an X509 certificate.
const struct __CFArray * CFArrayRef
void start()
Starts this timer.
static QList< QSslCertificate > fromData(const QByteArray &data, QSsl::EncodingFormat format=QSsl::Pem)
Searches for and parses all certificates in data that are encoded in the specified format and returns...

◆ transmit()

virtual void QSslSocketPrivate::transmit ( )
pure virtual

◆ unixRootCertDirectories()

QList< QByteArray > QSslSocketPrivate::unixRootCertDirectories ( )
staticprotected
Warning
This function is not part of the public interface.

Definition at line 2385 of file qsslsocket.cpp.

Referenced by ensureCiphersAndCertsLoaded(), QSslSocketBackendPrivate::initSslContext(), and systemCaCertificates().

2386 {
2387  return QList<QByteArray>() << "/etc/ssl/certs/" // (K)ubuntu, OpenSUSE, Mandriva, MeeGo ...
2388  << "/usr/lib/ssl/certs/" // Gentoo, Mandrake
2389  << "/usr/share/ssl/" // Centos, Redhat, SuSE
2390  << "/usr/local/ssl/" // Normal OpenSSL Tarball
2391  << "/var/ssl/certs/" // AIX
2392  << "/usr/local/ssl/certs/" // Solaris
2393  << "/etc/openssl/certs/" // BlackBerry
2394  << "/opt/openssl/certs/"; // HP-UX
2395 }

Properties

◆ allowRootCertOnDemandLoading

bool QSslSocketPrivate::allowRootCertOnDemandLoading

Definition at line 123 of file qsslsocket_p.h.

Referenced by QSslSocketBackendPrivate::initSslContext().

◆ autoStartHandshake

bool QSslSocketPrivate::autoStartHandshake

◆ configuration

QSslConfigurationPrivate QSslSocketPrivate::configuration

◆ connectionEncrypted

bool QSslSocketPrivate::connectionEncrypted

◆ ignoreAllSslErrors

bool QSslSocketPrivate::ignoreAllSslErrors

Definition at line 112 of file qsslsocket_p.h.

Referenced by init(), and QSslSocketBackendPrivate::startHandshake().

◆ ignoreErrorsList

QList<QSslError> QSslSocketPrivate::ignoreErrorsList

Definition at line 113 of file qsslsocket_p.h.

Referenced by QSslSocketBackendPrivate::startHandshake().

◆ initialized

bool QSslSocketPrivate::initialized

Definition at line 106 of file qsslsocket_p.h.

◆ mode

QSslSocket::SslMode QSslSocketPrivate::mode

◆ plainSocket

QTcpSocket* QSslSocketPrivate::plainSocket

◆ ptrSecCertificateGetData

PtrSecCertificateGetData QSslSocketPrivate::ptrSecCertificateGetData = 0
static

Definition at line 143 of file qsslsocket_p.h.

Referenced by ensureCiphersAndCertsLoaded(), and systemCaCertificates().

◆ ptrSecTrustCopyAnchorCertificates

PtrSecTrustCopyAnchorCertificates QSslSocketPrivate::ptrSecTrustCopyAnchorCertificates = 0
static

Definition at line 145 of file qsslsocket_p.h.

Referenced by ensureCiphersAndCertsLoaded(), and systemCaCertificates().

◆ ptrSecTrustSettingsCopyCertificates

PtrSecTrustSettingsCopyCertificates QSslSocketPrivate::ptrSecTrustSettingsCopyCertificates = 0
static

Definition at line 144 of file qsslsocket_p.h.

Referenced by ensureCiphersAndCertsLoaded(), and systemCaCertificates().

◆ readyReadEmittedPointer

bool* QSslSocketPrivate::readyReadEmittedPointer

Definition at line 114 of file qsslsocket_p.h.

Referenced by _q_readyReadSlot(), and QSslSocketBackendPrivate::transmit().

◆ s_libraryLoaded

bool QSslSocketPrivate::s_libraryLoaded = false
staticprivate

Definition at line 184 of file qsslsocket_p.h.

Referenced by ensureLibraryLoaded().

◆ s_loadedCiphersAndCerts

bool QSslSocketPrivate::s_loadedCiphersAndCerts = false
staticprivate

Definition at line 185 of file qsslsocket_p.h.

Referenced by ensureCiphersAndCertsLoaded().

◆ s_loadRootCertsOnDemand

bool QSslSocketPrivate::s_loadRootCertsOnDemand = false
staticprotected

◆ shutdown

bool QSslSocketPrivate::shutdown

◆ sslErrors

QList<QSslError> QSslSocketPrivate::sslErrors

Definition at line 117 of file qsslsocket_p.h.

Referenced by QSslSocketBackendPrivate::startHandshake().

◆ verificationPeerName

QString QSslSocketPrivate::verificationPeerName

The documentation for this class was generated from the following files: