[Interest] QWebSocketServer via https
Alexander Carôt
alexander_carot at gmx.net
Fri Jul 17 09:59:06 CEST 2020
P.S.: I also added to the constructor the following:
QSslConfiguration sslConfiguration;
QFile certFile(QStringLiteral(":/localhost.cert"));
QFile keyFile(QStringLiteral(":/localhost.key"));
certFile.open(QIODevice::ReadOnly);
keyFile.open(QIODevice::ReadOnly);
QSslCertificate certificate(&certFile, QSsl::Pem);
QSslKey sslKey(&keyFile, QSsl::Rsa, QSsl::Pem);
certFile.close();
keyFile.close();
sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyNone);
sslConfiguration.setLocalCertificate(certificate);
sslConfiguration.setPrivateKey(sslKey);
m_pWebSocketServer->setSslConfiguration(sslConfiguration);
If it does not work do I probably have to change something regarding the certificates in this case when it is deployed on a public server ?
--
http://www.carot.de
Email : Alexander at Carot.de
Tel.: +49 (0)177 5719797
> Gesendet: Freitag, 17. Juli 2020 um 09:48 Uhr
> Von: "Alexander Carôt" <alexander_carot at gmx.net>
> An: "qt qt" <interest at qt-project.org>
> Betreff: QWebSocketServer via https
>
> Hello all,
>
> I have been running a QWebSocketServer for a couple of years already and decided to switch from non-secure to secure mode now.
>
> My implementation is based on the Qt example Echoserver.cpp and what I did is this:
>
> 1.) Replaced the call
>
> m_pWebSocketServer(new QWebSocketServer(QStringLiteral("Echo Server"),
> QWebSocketServer::NonSecureMode, this)),
> with
>
> m_pWebSocketServer(new QWebSocketServer(QStringLiteral("Echo Server"),
> QWebSocketServer::SecureMode, this)),
>
> 2.) In my javascript based Webfile I replaced
>
> websocket = new WebSocket(ws://webSocketDomain:port);
>
> with
>
> websocket = new WebSocket(wss://webSocketDomain:port);
>
>
> After the change the browser tells me:
>
> Can't establish connection to wss://webSocketDomain:port
>
> That being said I assume that further actions are required - can anyone advise ?
>
> Thanks a lot in advance,
> best
>
> Alex
>
>
>
>
> --
> http://www.carot.de
> Email : Alexander at Carot.de
> Tel.: +49 (0)177 5719797
>
More information about the Interest
mailing list