diff options
Diffstat (limited to 'src/network/ssl/qsslsocket.cpp')
-rw-r--r-- | src/network/ssl/qsslsocket.cpp | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 9b5d90225f..805adc734f 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -131,19 +131,18 @@ before the handshake phase with setLocalCertificate() and setPrivateKey(). \li The CA certificate database can be extended and customized with - addCaCertificate(), addCaCertificates(), setCaCertificates(), - addDefaultCaCertificate(), addDefaultCaCertificates(), and - setDefaultCaCertificates(). + addCaCertificate(), addCaCertificates(), addDefaultCaCertificate(), + addDefaultCaCertificates(), and QSslConfiguration::defaultConfiguration().setCaCertificates(). \endlist \note If available, root certificates on Unix (excluding OS X) will be - loaded on demand from the standard certificate directories. If - you do not want to load root certificates on demand, you need to call either - the static function setDefaultCaCertificates() before the first SSL handshake - is made in your application, (e.g. via - "QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates());"), - or call setCaCertificates() on your QSslSocket instance prior to the SSL - handshake. + loaded on demand from the standard certificate directories. If you do not + want to load root certificates on demand, you need to call either + QSslConfiguration::defaultConfiguration().setCaCertificates() before the first + SSL handshake is made in your application (for example, via passing + QSslSocket::systemCaCertificates() to it), or call + QSslConfiguration::defaultConfiguration()::setCaCertificates() on your QSslSocket instance + prior to the SSL handshake. For more information about ciphers and certificates, refer to QSslCipher and QSslCertificate. @@ -499,8 +498,7 @@ bool QSslSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState state d->createPlainSocket(openMode); bool retVal = d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode); d->cachedSocketDescriptor = d->plainSocket->socketDescriptor(); - setSocketError(d->plainSocket->error()); - setErrorString(d->plainSocket->errorString()); + d->setError(d->plainSocket->error(), d->plainSocket->errorString()); setSocketState(state); setOpenMode(openMode); setLocalPort(d->plainSocket->localPort()); @@ -1243,7 +1241,7 @@ void QSslSocket::setCiphers(const QString &ciphers) { Q_D(QSslSocket); d->configuration.ciphers.clear(); - foreach (const QString &cipherName, ciphers.split(QLatin1String(":"),QString::SkipEmptyParts)) { + foreach (const QString &cipherName, ciphers.split(QLatin1Char(':'), QString::SkipEmptyParts)) { QSslCipher cipher(cipherName); if (!cipher.isNull()) d->configuration.ciphers << cipher; @@ -1532,8 +1530,7 @@ bool QSslSocket::waitForConnected(int msecs) bool retVal = d->plainSocket->waitForConnected(msecs); if (!retVal) { setSocketState(d->plainSocket->state()); - setSocketError(d->plainSocket->error()); - setErrorString(d->plainSocket->errorString()); + d->setError(d->plainSocket->error(), d->plainSocket->errorString()); } return retVal; } @@ -1688,8 +1685,7 @@ bool QSslSocket::waitForDisconnected(int msecs) bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed())); if (!retVal) { setSocketState(d->plainSocket->state()); - setSocketError(d->plainSocket->error()); - setErrorString(d->plainSocket->errorString()); + d->setError(d->plainSocket->error(), d->plainSocket->errorString()); } return retVal; } @@ -2402,8 +2398,9 @@ void QSslSocketPrivate::_q_stateChangedSlot(QAbstractSocket::SocketState state) */ void QSslSocketPrivate::_q_errorSlot(QAbstractSocket::SocketError error) { - Q_Q(QSslSocket); + Q_UNUSED(error) #ifdef QSSLSOCKET_DEBUG + Q_Q(QSslSocket); qCDebug(lcSsl) << "QSslSocket::_q_errorSlot(" << error << ')'; qCDebug(lcSsl) << "\tstate =" << q->state(); qCDebug(lcSsl) << "\terrorString =" << q->errorString(); @@ -2416,9 +2413,7 @@ void QSslSocketPrivate::_q_errorSlot(QAbstractSocket::SocketError error) readBufferMaxSize = tmpReadBufferMaxSize; } - q->setSocketError(plainSocket->error()); - q->setErrorString(plainSocket->errorString()); - emit q->error(error); + setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); } /*! @@ -2483,7 +2478,6 @@ void QSslSocketPrivate::_q_flushReadBuffer() */ void QSslSocketPrivate::_q_resumeImplementation() { - Q_Q(QSslSocket); if (plainSocket) plainSocket->resume(); paused = false; @@ -2491,9 +2485,7 @@ void QSslSocketPrivate::_q_resumeImplementation() if (verifyErrorsHaveBeenIgnored()) { continueHandshake(); } else { - q->setErrorString(sslErrors.first().errorString()); - q->setSocketError(QAbstractSocket::SslHandshakeFailedError); - emit q->error(QAbstractSocket::SslHandshakeFailedError); + setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError, sslErrors.first().errorString()); plainSocket->disconnectFromHost(); return; } |