From 699f772bffab3ae0a6399f56d7154e333a273d6c Mon Sep 17 00:00:00 2001 From: Kurt Pattyn Date: Wed, 12 Mar 2014 11:23:24 +0100 Subject: Fix for self-signed certificates Change-Id: I529976e6fc8813d273290e97e86405f51c3efa57 Reviewed-by: Kurt Pattyn --- examples/sslechoclient/sslechoclient.cpp | 12 ++++++++++++ examples/sslechoclient/sslechoclient.h | 9 +++++---- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/sslechoclient/sslechoclient.cpp b/examples/sslechoclient/sslechoclient.cpp index fdf00df..cf5b976 100644 --- a/examples/sslechoclient/sslechoclient.cpp +++ b/examples/sslechoclient/sslechoclient.cpp @@ -40,6 +40,8 @@ ****************************************************************************/ #include "sslechoclient.h" #include +#include +#include QT_USE_NAMESPACE @@ -49,6 +51,9 @@ SslEchoClient::SslEchoClient(const QUrl &url, QObject *parent) : m_webSocket() { connect(&m_webSocket, &QWebSocket::connected, this, &SslEchoClient::onConnected); + typedef void (QWebSocket:: *sslErrorsSignal)(const QList &); + connect(&m_webSocket, static_cast(&QWebSocket::sslErrors), + this, &SslEchoClient::onSslErrors); m_webSocket.open(QUrl(url)); } //! [constructor] @@ -67,5 +72,12 @@ void SslEchoClient::onConnected() void SslEchoClient::onTextMessageReceived(QString message) { qDebug() << "Message received:" << message; + qApp->quit(); +} + +void SslEchoClient::onSslErrors(const QList &errors) +{ + Q_UNUSED(errors); + m_webSocket.ignoreSslErrors(); } //! [onTextMessageReceived] diff --git a/examples/sslechoclient/sslechoclient.h b/examples/sslechoclient/sslechoclient.h index cec9e9d..7ec373b 100644 --- a/examples/sslechoclient/sslechoclient.h +++ b/examples/sslechoclient/sslechoclient.h @@ -43,6 +43,10 @@ #include #include +#include +#include +#include +#include QT_FORWARD_DECLARE_CLASS(QWebSocket) @@ -52,13 +56,10 @@ class SslEchoClient : public QObject public: explicit SslEchoClient(const QUrl &url, QObject *parent = Q_NULLPTR); -Q_SIGNALS: - -public Q_SLOTS: - private Q_SLOTS: void onConnected(); void onTextMessageReceived(QString message); + void onSslErrors(const QList &errors); private: QWebSocket m_webSocket; -- cgit v1.2.1