From d122d15b66bdcecb42f4c3cabaeaab6791f1edaa Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Fri, 28 Feb 2014 12:31:13 +0100 Subject: Doc: Review documentation Qt WebSockets Task-number: QTBUG-37149 Change-Id: Ia8fe7b11140d31bc231a17bfcc16887f3af0dbce Reviewed-by: Jerome Pasion --- examples/doc/echoclient.qdoc | 5 ++++- examples/doc/echoserver.qdoc | 6 ++++-- examples/doc/qmlwebsocketclient.qdoc | 1 + examples/doc/simplechat.qdoc | 5 ++++- examples/doc/sslechoclient.qdoc | 2 ++ examples/doc/sslechoserver.qdoc | 2 ++ examples/examples.qdoc | 3 +-- 7 files changed, 18 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/doc/echoclient.qdoc b/examples/doc/echoclient.qdoc index a1f1646..a6cb1a9 100644 --- a/examples/doc/echoclient.qdoc +++ b/examples/doc/echoclient.qdoc @@ -43,7 +43,10 @@ \example echoclient \title Echo Client Example \ingroup qtwebsockets-examples - \brief Explains how to use the websocket API to create a simple echo client. + \brief Describes how to use the websocket API for creating a simple echo client. + + The Echo Client Example shows how to use the websocket API to create a simple + echo client. \sa {Echo Server Example} */ diff --git a/examples/doc/echoserver.qdoc b/examples/doc/echoserver.qdoc index b7b8299..fcb0442 100644 --- a/examples/doc/echoserver.qdoc +++ b/examples/doc/echoserver.qdoc @@ -43,9 +43,11 @@ \example echoserver \title Echo Server Example \ingroup qtwebsockets-examples + \brief Shows how to create a simple server application that + sends back the messages it receives. - The Echo Server example shows how to create a simple server application that - sends back the messages that it receives, using the websockets API. + The Echo Server Example shows how to create a simple server application that + sends back the messages it receives, using the websockets API. \sa {Echo Client Example} */ diff --git a/examples/doc/qmlwebsocketclient.qdoc b/examples/doc/qmlwebsocketclient.qdoc index 0bf39bd..776e486 100644 --- a/examples/doc/qmlwebsocketclient.qdoc +++ b/examples/doc/qmlwebsocketclient.qdoc @@ -43,4 +43,5 @@ \example qmlwebsocketclient \title QML WebSocket Client Example \ingroup qtwebsockets-examples + \brief Explains how to program a QML WebSocket client example. */ diff --git a/examples/doc/simplechat.qdoc b/examples/doc/simplechat.qdoc index 215c46a..506d45a 100644 --- a/examples/doc/simplechat.qdoc +++ b/examples/doc/simplechat.qdoc @@ -43,7 +43,10 @@ \example simplechat \title Simple Chat Example \ingroup qtwebsockets-examples + \brief Shows how to use the QWebSocket and QWebSocketServer classes + for creating a minimalistic chat application over websockets. - The Simple Chat example shows how to use the QWebSocket and QWebSocketServer + The Simple Chat Example shows how to use the QWebSocket and QWebSocketServer classes to create a minimalistic chat application over websockets. + */ diff --git a/examples/doc/sslechoclient.qdoc b/examples/doc/sslechoclient.qdoc index ca515ec..d7d1897 100644 --- a/examples/doc/sslechoclient.qdoc +++ b/examples/doc/sslechoclient.qdoc @@ -43,6 +43,8 @@ \example sslechoclient \title SSL Echo Client Example \ingroup qtwebsockets-examples + \brief Shows how to use the QWebSocket class to implement an echo + client over a secure connection (wss). The SSL Echo Client example shows how to use the QWebSocket class to implement an echo client over a secure connection (wss). diff --git a/examples/doc/sslechoserver.qdoc b/examples/doc/sslechoserver.qdoc index 608b27a..d158a68 100644 --- a/examples/doc/sslechoserver.qdoc +++ b/examples/doc/sslechoserver.qdoc @@ -43,6 +43,8 @@ \example sslechoserver \title SSL Echo Server Example \ingroup qtwebsockets-examples + \brief Shows how to use the QWebSocketServer class for implementing a simple + echo server over secure sockets (wss). The SSL Echo Server example shows how to use the QWebSocketServer class to implement a simple echo server over secure sockets (wss). diff --git a/examples/examples.qdoc b/examples/examples.qdoc index b770704..bc1ad32 100644 --- a/examples/examples.qdoc +++ b/examples/examples.qdoc @@ -45,8 +45,7 @@ \page examples.html \brief List of Qt WebSocket examples - The module provides the following examples for reference to - help understand the API usage: + The examples below can be used as a guide to using the API. \list \li \l echoclient -- cgit v1.2.1 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 From d4ac9f51f6d18a05016e3d61c06eace27501f589 Mon Sep 17 00:00:00 2001 From: Kurt Pattyn Date: Wed, 12 Mar 2014 14:53:00 +0100 Subject: Add warning to example regarding ignoring ssl errors Change-Id: I3d615a774f4071a085b0f233bef2eac76aefbefb Reviewed-by: Richard J. Moore --- examples/sslechoclient/sslechoclient.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'examples') diff --git a/examples/sslechoclient/sslechoclient.cpp b/examples/sslechoclient/sslechoclient.cpp index cf5b976..037990d 100644 --- a/examples/sslechoclient/sslechoclient.cpp +++ b/examples/sslechoclient/sslechoclient.cpp @@ -78,6 +78,11 @@ void SslEchoClient::onTextMessageReceived(QString message) void SslEchoClient::onSslErrors(const QList &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] -- cgit v1.2.1