summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKurt Pattyn <pattyn.kurt@gmail.com>2014-03-12 11:23:24 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-12 11:45:34 +0100
commit699f772bffab3ae0a6399f56d7154e333a273d6c (patch)
tree6aa84c0e7e5ade274abb3970054463b993e8a6ea /examples
parent89dcdaeedf0e42e99ccc1d44183e1fbaccc40bb1 (diff)
downloadqtwebsockets-699f772bffab3ae0a6399f56d7154e333a273d6c.tar.gz
Fix for self-signed certificates
Change-Id: I529976e6fc8813d273290e97e86405f51c3efa57 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/sslechoclient/sslechoclient.cpp12
-rw-r--r--examples/sslechoclient/sslechoclient.h9
2 files changed, 17 insertions, 4 deletions
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 <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,12 @@ void SslEchoClient::onConnected()
void SslEchoClient::onTextMessageReceived(QString message)
{
qDebug() << "Message received:" << message;
+ qApp->quit();
+}
+
+void SslEchoClient::onSslErrors(const QList<QSslError> &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 <QtCore/QObject>
#include <QtWebSockets/QWebSocket>
+#include <QtNetwork/QSslError>
+#include <QtCore/QList>
+#include <QtCore/QString>
+#include <QtCore/QUrl>
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<QSslError> &errors);
private:
QWebSocket m_webSocket;