Commit 699f772b authored by Kurt Pattyn's avatar Kurt Pattyn Committed by The Qt Project
Browse files

Fix for self-signed certificates


Change-Id: I529976e6fc8813d273290e97e86405f51c3efa57
Reviewed-by: default avatarKurt Pattyn <pattyn.kurt@gmail.com>
parent 89dcdaee
No related merge requests found
Showing with 17 additions and 4 deletions
......@@ -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]
......@@ -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;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment