#1 2021-05-25 10:08:59

flydev
Member
From: France
Registered: 2020-11-27
Posts: 50
Website

TSQLHTTPServer, WebSockets and SSL

Hi everyone,

I am maybe starting a dumb question, it's possible to have a TSQLHTTPServer running with useBidirSocket and secSsl ?

I am trying to upgrade a current project to use SSL because I have a ServiceMethod which return HTML content with some javascript. In this javascript code, I call the WebAPI "navigator.share" which only works on secure (HTTPS) domains.

So I created a self-signed certificate, registered the route, everything good at this point, I can browse the document on HTTPS and execute the javascript code.

The server answer some interface services, and send push notification through websockets, but to get HTTPS working, I had to change "useBiDirSocket" to  "useHttpApiRegisteringURI" to the server declaration, but after this change, I am out of WebSockets support :

fRestServer := TRestServerDB.Create(fModel, 'vremotesagas.db', true);
fHttpServer := TSQLHTTPServer.Create(PORT_NAME, [fRestServer], SERVER_URL, useHttpApiRegisteringURI, 32, secSsl); // initially set with useBidirSocket and secNone
// fHttpServer.WebSocketsEnable(fRestServer, SAGAS_TRANSMISSION_KEY);//.Settings.ClientAutoUpgrade := true;

If I set "useBiDirSocket" with "secSsl" and try to browse a document on HTTPS, i get an AV on "mormot.rest.http.server" line 1020 :

// call matching TRestServer.Uri()
call.Method := Ctxt.Method;
call.InHead := Ctxt.InHeaders;
call.InBody := Ctxt.InContent;
serv.Uri(call);     <------------------- serv is nil

Offline

#2 2021-05-25 15:11:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: TSQLHTTPServer, WebSockets and SSL

We usually use a nginx reverse proxy for this.

Offline

#3 2021-05-26 05:55:38

flydev
Member
From: France
Registered: 2020-11-27
Posts: 50
Website

Re: TSQLHTTPServer, WebSockets and SSL

Thanks @ab, effectively, this is something I didn't think of.

Offline

Board footer

Powered by FluxBB