Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. WebAssembly: Https request with custom certificate
QtWS25 Last Chance

WebAssembly: Https request with custom certificate

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
httpssslwebassemblycertificate
5 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mixlu
    wrote on last edited by Mixlu
    #1

    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 and QSslConfiguration.

    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 ?

    1 Reply Last reply
    0
    • hskoglundH Online
      hskoglundH Online
      hskoglund
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      1
      • hskoglundH hskoglund

        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

        M Offline
        M Offline
        Mixlu
        wrote on last edited by Mixlu
        #3

        @hskoglund thanks for your reply,

        Ok I see, but I can't use WebSockets because of the server side.

        I was thinking to use native javascript but I wouldn't be able to add a custom certificate.

        Is there an alternative ?

        1 Reply Last reply
        0
        • hskoglundH Online
          hskoglundH Online
          hskoglund
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • hskoglundH hskoglund

            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

            M Offline
            M Offline
            Mixlu
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved