[Interest] QWebSocketServer via https
Alexander Carôt
alexander_carot at gmx.net
Fri Jul 17 19:17:27 CEST 2020
P.P.S.:
Just solved the problem myself - it was indeed related to the
localhost.cert and the localhot.key files, which I had to replace with the respective server's files.
All working fine now - thanks anyways !
--
http://www.carot.de
Email : Alexander at Carot.de
Tel.: +49 (0)177 5719797
> Gesendet: Freitag, 17. Juli 2020 um 09:59 Uhr
> Von: "Alexander Carôt" <alexander_carot at gmx.net>
> An: "qt qt" <interest at qt-project.org>
> Betreff: Re: [Interest] QWebSocketServer via https
>
> 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
> >
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
More information about the Interest
mailing list