Details
-
Suggestion
-
Resolution: Fixed
-
P2: Important
-
6.4.1
-
None
-
-
8
-
6821b4426 (dev), 2288aa3ca (6.5)
-
Foundation Sprint 77
Description
The SSL Echo Server/Client example is meant to demonstrate how to set up a secure local WebSocket channel. The example server uses a self-signed certificate. The example client, however, does not set this certificate - in fact it does not do any SSL configuration at all, and explicitly ignores all SSL errors. This is a bit underwhelming.
Note that there is a complete other set of examples (Echo Server/Client) demonstrating non-secure WebSocket communication, so the only reason anyone would look at this example is to find out how the SSL configuration works - which the example then utterly fails to demonstrate.
To fix, this, the following would have to be added to the SslEchoClient constructor:
QSslConfiguration sslConfiguration; sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyPeer); QFile certFile(QStringLiteral(":/localhost.cert")); assert(certFile.open(QIODevice::ReadOnly)); QSslCertificate certificate(&certFile, QSsl::Pem); certFile.close(); sslConfiguration.addCaCertificate(certificate); m_webSocket.setSslConfiguration(sslConfiguration);
and of course the localhost.cert file from the server added to the client's resources.