aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2020-11-24 14:46:38 +0100
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2020-11-24 16:55:39 +0100
commitd1e892816fba1494d9a63fc22a88d78c2bbe0429 (patch)
tree3b48dc625ece9fbc63edc1e31c657c95ed36596a /src
parent1a556baf525ec5d6b03c40e890ee861da829a7b7 (diff)
QWebSocket: websocket is a websocket, not a TLS socket necessary
So we delay TLS initialization until it's really required (wss scheme found etc). Fixes: QTBUG-88663 Change-Id: I0c1cfa03b189bfa8e41aad27918fe1998de19ea7 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/websockets/qwebsocket_p.cpp1
-rw-r--r--src/websockets/qwebsocket_p.h19
2 files changed, 18 insertions, 2 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp
index 5a95215..aedc3c6 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -74,7 +74,6 @@ const quint64 DEFAULT_OUTGOING_FRAME_SIZE_IN_BYTES = 512 * 512 * 2; //default si
QWebSocketConfiguration::QWebSocketConfiguration() :
#ifndef QT_NO_SSL
- m_sslConfiguration(QSslConfiguration::defaultConfiguration()),
m_ignoredSslErrors(),
m_ignoreSslErrors(false),
#endif
diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h
index ad667aa..c193a70 100644
--- a/src/websockets/qwebsocket_p.h
+++ b/src/websockets/qwebsocket_p.h
@@ -90,7 +90,24 @@ public:
public:
#ifndef QT_NO_SSL
- QSslConfiguration m_sslConfiguration;
+ struct TlsConfigurationLazy {
+ TlsConfigurationLazy &operator = (const QSslConfiguration &rhs)
+ {
+ tlsConfiguration.reset(new QSslConfiguration(rhs));
+ return *this;
+ }
+
+ operator QSslConfiguration() const
+ {
+ if (!tlsConfiguration.get())
+ tlsConfiguration.reset(new QSslConfiguration(QSslConfiguration::defaultConfiguration()));
+ return *tlsConfiguration.get();
+ }
+
+ mutable std::unique_ptr<QSslConfiguration> tlsConfiguration;
+ };
+
+ TlsConfigurationLazy m_sslConfiguration;
QList<QSslError> m_ignoredSslErrors;
bool m_ignoreSslErrors;
#endif