summaryrefslogtreecommitdiffstats
path: root/examples/remoteobjects/ssl/doc
diff options
context:
space:
mode:
authorØystein Heskestad <oystein.heskestad@qt.io>2023-05-22 16:41:35 +0200
committerØystein Heskestad <oystein.heskestad@qt.io>2023-06-06 07:35:51 +0000
commit743de69538696ea14e299c32056d40851bb9fdcd (patch)
treebbe4b9197043614d8d13700afa383257ed75f081 /examples/remoteobjects/ssl/doc
parent98522adc399e4fcd97808a0ae4c3a231d6c67739 (diff)
Revamp SSL example
The example did not work because the two applications used different rep-files to generate the remote objects. Use the same file in both applications, fix usage of case in naming, expand the documentation, and add a picture. Remove unused PresetData from rep-file. Task-number: QTBUG-112850 Pick-to: 6.5 6.6 Change-Id: Ia7aafc52d647bca9ffec12b8dd548377f20b6ce4 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/remoteobjects/ssl/doc')
-rw-r--r--examples/remoteobjects/ssl/doc/src/ssl.qdoc69
1 files changed, 67 insertions, 2 deletions
diff --git a/examples/remoteobjects/ssl/doc/src/ssl.qdoc b/examples/remoteobjects/ssl/doc/src/ssl.qdoc
index 90b6725..3ceeece 100644
--- a/examples/remoteobjects/ssl/doc/src/ssl.qdoc
+++ b/examples/remoteobjects/ssl/doc/src/ssl.qdoc
@@ -3,10 +3,75 @@
/*!
\example ssl
- \title QtRemoteObjects SSL Example
+ \title SSL Server and Client
\brief Setting up a secure Remote Object network using QSslSockets.
+ \examplecategory {Input/Output}
+ \meta tag {rpc,network,tls}
\ingroup qtremoteobjects-examples
Encrypting communication is critical when you need to pass data
- through a network you don't have full control over.
+ through a network you don't have full control over. The two applications
+ in this example show how to share remote objects over an SSL connection,
+ and how to access them.
+
+ \image ssl-example.webp
+
+ Both \e sslserver and \e sslcppclient use a custom root CA certificate to
+ validate each other's certificates all located in sslserver/cert.
+
+ \section1 SSL Server
+
+ The \e sslserver is configured with certificates and a private key.
+
+ \snippet ssl/sslserver/main.cpp 0
+
+ Then it creates a QRemoteObjectHost object and a QSslServer object.
+ The QSslServer object listens on port 65511. Then setHostUrl is called
+ on the QRemoteObjectHost object with the URL of the QSslServer object.
+
+ \snippet ssl/sslserver/main.cpp 1
+
+ A lambda is used to handle the errorOccurred signal by outputting the
+ error to the terminal. A second lambda is connected to the
+ pendingConnectionAvailable signal, which connects an error handler,
+ and calls addHostSideConnection on the QRemoteObjectHost object with
+ the incoming socket as argument to make the host object use the socket
+ for communication.
+
+ \snippet ssl/sslserver/main.cpp 2
+
+ Finally, a MinuteTimer object is created and enableRemoting is called on
+ the QRemoteObjectHost object with the MinuteTimer object as argument to
+ enable it to be shared.
+
+ \snippet ssl/sslserver/main.cpp 3
+
+ \section1 SSL Client
+
+ The \e sslcppclient sets the root CA certificate and then creates a
+ Tester object.
+
+ \snippet ssl/sslcppclient/main.cpp 3
+
+ In the Tester constructor a temporary QRemoteObjectNode object is
+ created, and setupConnection is used to create and configure a
+ QSslSocket object. An error handler is connected, and the QSslSocket is
+ used by the QRemoteObjectNode object by calling addClientSideConnection
+ on it.
+
+ \snippet ssl/sslcppclient/main.cpp 0
+
+ Then three QScopedPointer that are members of the Tester class are
+ connected to three replicas of MinuteTimer by using acquire on the
+ QRemoteObjectNode object. Finally QTimer::singleShot is used four times
+ to call reset after a delay.
+
+ \snippet ssl/sslcppclient/main.cpp 1
+
+ When Tester::clear is called for the first three times, one pointer is
+ checked that it is bound and then reset, for a different pointer each
+ time. When it is called for the fourth time it causes the application
+ to quit.
+
+ \snippet ssl/sslcppclient/main.cpp 2
*/