WebAssembly: Https request with custom certificate
-
Hi,
I am working on a Qt 5.13 project in WebAssembly with emscripten 1.38.30.
I am trying to create a GET HTTPS request to a server with a custom certificate.I added my certificate like this:
QNetworkRequest _request = QNetworkRequest(); QSslConfiguration sslconf = QSslConfiguration(); sslconf.setCaCertificates(QSslCertificate::fromPath("C:/SimpleServerCertificate/certificate.pem")); _request.setSslConfiguration(sslconf);
It works on MinGW (windows) but not in WebAssembly. It seems that the compiler don't recognize
QNetworkRequest
andQSslConfiguration
.I have also tried to include OpenSsl as a library (compiled in webassembly) as follow but didn't help:
INCLUDEPATH += "$$PWD/openssl-wasm/include" LIBS += -L"$$PWD/openssl-wasm" -llibcrypto -llibssl
WebAssembly doesn't support ssl / https request ? Is there a way to do it ?
-
Hi, Qt for WebAssembly can not use ssl, bugreport here: https://bugreports.qt.io/browse/QTBUG-76350
Also https is very tricky over WebAssembly, the recommended way is to use WebSockets instead, more here https://emscripten.org/docs/porting/networking.html
-
Well WebAssembly is pretty strict, if you want to make https requests you need to use a proxy/bridge program that translates from websockets to http, it's installed on a PC on the same LAN as the WebAssembly PC (or on the same PC). For example you could use this one: https://github.com/novnc/websockify