summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp11
-rw-r--r--src/plugins/tls/openssl/qdtls_openssl.cpp6
-rw-r--r--src/plugins/tls/openssl/qtls_openssl.cpp10
3 files changed, 13 insertions, 14 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 22b1cd0ec3..5c0097daa5 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -393,8 +393,8 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
// check whether we can re-use an existing SSL session
// (meaning another socket in this connection has already
// performed a full handshake)
- if (!connection->sslContext().isNull())
- QSslSocketPrivate::checkSettingSslContext(sslSocket, connection->sslContext());
+ if (auto ctx = connection->sslContext())
+ QSslSocketPrivate::checkSettingSslContext(sslSocket, std::move(ctx));
sslSocket->setPeerVerifyName(connection->d_func()->peerVerifyName);
sslSocket->connectToHostEncrypted(connectHost, connectPort, QIODevice::ReadWrite, networkLayerPreference);
@@ -925,12 +925,11 @@ void QHttpNetworkConnectionChannel::_q_connected()
//channels[i].reconnectAttempts = 2;
if (ssl || pendingEncrypt) { // FIXME: Didn't work properly with pendingEncrypt only, we should refactor this into an EncrypingState
#ifndef QT_NO_SSL
- if (connection->sslContext().isNull()) {
+ if (!connection->sslContext()) {
// this socket is making the 1st handshake for this connection,
// we need to set the SSL context so new sockets can reuse it
- QSharedPointer<QSslContext> socketSslContext = QSslSocketPrivate::sslContext(static_cast<QSslSocket*>(socket));
- if (!socketSslContext.isNull())
- connection->setSslContext(socketSslContext);
+ if (auto socketSslContext = QSslSocketPrivate::sslContext(static_cast<QSslSocket*>(socket)))
+ connection->setSslContext(std::move(socketSslContext));
}
#endif
} else if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct) {
diff --git a/src/plugins/tls/openssl/qdtls_openssl.cpp b/src/plugins/tls/openssl/qdtls_openssl.cpp
index d8b850f576..a1f2c707f9 100644
--- a/src/plugins/tls/openssl/qdtls_openssl.cpp
+++ b/src/plugins/tls/openssl/qdtls_openssl.cpp
@@ -605,7 +605,7 @@ bool DtlsState::init(QDtlsBasePrivate *dtlsBase, QUdpSocket *socket,
Q_ASSERT(dtlsBase);
Q_ASSERT(socket);
- if (!tlsContext.data() && !initTls(dtlsBase))
+ if (!tlsContext && !initTls(dtlsBase))
return false;
udpSocket = socket;
@@ -632,7 +632,7 @@ void DtlsState::reset()
bool DtlsState::initTls(QDtlsBasePrivate *dtlsBase)
{
- if (tlsContext.data())
+ if (tlsContext)
return true;
if (!QSslSocket::supportsSsl())
@@ -716,7 +716,7 @@ bool DtlsState::initCtxAndConnection(QDtlsBasePrivate *dtlsBase)
bool DtlsState::initBIO(QDtlsBasePrivate *dtlsBase)
{
Q_ASSERT(dtlsBase);
- Q_ASSERT(tlsContext.data() && tlsConnection.data());
+ Q_ASSERT(tlsContext && tlsConnection);
BioMethod customMethod(q_BIO_meth_new(BIO_TYPE_DGRAM, dtlsbio::qdtlsMethodName),
dtlsutil::delete_bio_method);
diff --git a/src/plugins/tls/openssl/qtls_openssl.cpp b/src/plugins/tls/openssl/qtls_openssl.cpp
index dbbd9b29a8..ec4303bcdc 100644
--- a/src/plugins/tls/openssl/qtls_openssl.cpp
+++ b/src/plugins/tls/openssl/qtls_openssl.cpp
@@ -506,8 +506,8 @@ void TlsCryptographOpenSSL::init(QSslSocket *qObj, QSslSocketPrivate *dObj)
void TlsCryptographOpenSSL::checkSettingSslContext(QSharedPointer<QSslContext> tlsContext)
{
- if (sslContextPointer.isNull())
- sslContextPointer = tlsContext;
+ if (!sslContextPointer)
+ sslContextPointer = std::move(tlsContext);
}
QSharedPointer<QSslContext> TlsCryptographOpenSSL::sslContext() const
@@ -815,7 +815,7 @@ void TlsCryptographOpenSSL::continueHandshake()
// Cache this SSL session inside the QSslContext
if (!(configuration.testSslOption(QSsl::SslOptionDisableSessionSharing))) {
if (!sslContextPointer->cacheSession(ssl)) {
- sslContextPointer.clear(); // we could not cache the session
+ sslContextPointer.reset(); // we could not cache the session
} else {
// Cache the session for permanent usage as well
if (!(configuration.testSslOption(QSsl::SslOptionDisableSessionPersistence))) {
@@ -1367,7 +1367,7 @@ bool TlsCryptographOpenSSL::initSslContext()
if (sslContextPointer->error() != QSslError::NoError) {
setErrorAndEmit(d, QAbstractSocket::SslInvalidUserDataError, sslContextPointer->errorString());
- sslContextPointer.clear(); // deletes the QSslContext
+ sslContextPointer.reset();
return false;
}
@@ -1495,7 +1495,7 @@ void TlsCryptographOpenSSL::destroySslContext()
q_SSL_free(ssl);
ssl = nullptr;
}
- sslContextPointer.clear();
+ sslContextPointer.reset();
}
void TlsCryptographOpenSSL::storePeerCertificates()