summaryrefslogtreecommitdiff
path: root/examples/sslechoclient/sslechoclient.cpp
diff options
context:
space:
mode:
authorSergio Ahumada <sahumada@blackberry.com>2014-03-13 14:50:03 +0100
committerSergio Ahumada <sahumada@blackberry.com>2014-03-13 14:50:05 +0100
commit974fd5f831cf9abfbd900c49ab6c21fb04ef62da (patch)
tree235666b5d896d5c86db5325215720425b5508ffa /examples/sslechoclient/sslechoclient.cpp
parente677361e300a7747a500c3879217727a53aae245 (diff)
parentd4ac9f51f6d18a05016e3d61c06eace27501f589 (diff)
downloadqtwebsockets-974fd5f831cf9abfbd900c49ab6c21fb04ef62da.tar.gz
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I0ee590f834200c488498315e66acf7cd046d43ad
Diffstat (limited to 'examples/sslechoclient/sslechoclient.cpp')
-rw-r--r--examples/sslechoclient/sslechoclient.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/sslechoclient/sslechoclient.cpp b/examples/sslechoclient/sslechoclient.cpp
index fdf00df..037990d 100644
--- a/examples/sslechoclient/sslechoclient.cpp
+++ b/examples/sslechoclient/sslechoclient.cpp
@@ -40,6 +40,8 @@
****************************************************************************/
#include "sslechoclient.h"
#include <QtCore/QDebug>
+#include <QtWebSockets/QWebSocket>
+#include <QCoreApplication>
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<QSslError> &);
+ connect(&m_webSocket, static_cast<sslErrorsSignal>(&QWebSocket::sslErrors),
+ this, &SslEchoClient::onSslErrors);
m_webSocket.open(QUrl(url));
}
//! [constructor]
@@ -67,5 +72,17 @@ void SslEchoClient::onConnected()
void SslEchoClient::onTextMessageReceived(QString message)
{
qDebug() << "Message received:" << message;
+ qApp->quit();
+}
+
+void SslEchoClient::onSslErrors(const QList<QSslError> &errors)
+{
+ Q_UNUSED(errors);
+
+ // WARNING: Never ignore SSL errors in production code.
+ // The proper way to handle self-signed certificates is to add a custom root
+ // to the CA store.
+
+ m_webSocket.ignoreSslErrors();
}
//! [onTextMessageReceived]