Recent

Author Topic: FPHTTPserver with SSL  (Read 1263 times)

fpc2pas

  • New Member
  • *
  • Posts: 34
FPHTTPserver with SSL
« on: May 04, 2022, 11:17:35 am »
I think recently there is an SSL support for fphttpserver, but I think the examples provided not really working, and tried to port something similar but also fails to generate or assign a self-signed cert, any ideas or demos?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: FPHTTPserver with SSL
« Reply #1 on: May 04, 2022, 12:04:10 pm »
See the example simpleserver in trunk's fpcsrc/fpc-3.3.1/packages/fcl-web/examples/simpleserver

fpc2pas

  • New Member
  • *
  • Posts: 34
Re: FPHTTPserver with SSL
« Reply #2 on: May 04, 2022, 12:16:49 pm »
See the example simpleserver in trunk's fpcsrc/fpc-3.3.1/packages/fcl-web/examples/simpleserver
that example is not working in Linux, also not on windows 10, there is some other examples or more docs ?

rvk

  • Hero Member
  • *****
  • Posts: 6162
Re: FPHTTPserver with SSL
« Reply #3 on: May 04, 2022, 12:24:26 pm »
See the example simpleserver in trunk's fpcsrc/fpc-3.3.1/packages/fcl-web/examples/simpleserver
that example is not working in Linux, also not on windows 10, there is some other examples or more docs ?
So for what platform is this example working?

"Is not working" isn't really a problem description.

Here is some more information. You could try to write your own (or explain more clearly what exactly "isn't working").
https://wiki.lazarus.freepascal.org/fpWeb_Tutorial

zeljko

  • Hero Member
  • *****
  • Posts: 1596
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: FPHTTPserver with SSL
« Reply #4 on: May 04, 2022, 01:33:16 pm »
I think recently there is an SSL support for fphttpserver, but I think the examples provided not really working, and tried to port something similar but also fails to generate or assign a self-signed cert, any ideas or demos?

I had similar problem, but now it works. I'm using synapse for ssl socket, just include opensslsockets into your lpr if you use synapse.
Also, I'm using self signed certs for testing and it works. Of course, eg. curl refuse to establish such connection because of self signed certificates, but with --insecure option it works ok.
Note: I've generated self signed certificates by using openssl under linux.

EDIT:  This is how I've setted up https server certificates:
    Application.UseSSL := True;
    Application.CertificateData.HostName := MyWebServerConfig.CertificateHostName;
    Application.CertificateData.KeyPassword:='';
    Application.CertificateData.PrivateKey.FileName := MyWebServerConfig.CertificatePrivateKey;
    Application.CertificateData.Certificate.FileName := MyWebServerConfig.CertificateCertificate;
« Last Edit: May 04, 2022, 01:35:55 pm by zeljko »

rvk

  • Hero Member
  • *****
  • Posts: 6162
Re: FPHTTPserver with SSL
« Reply #5 on: May 04, 2022, 01:37:36 pm »
Note: I've generated self signed certificates by using openssl under linux.
You could also try to use Let’s Encrypt (when unencrypted works).

fpc2pas

  • New Member
  • *
  • Posts: 34
Re: FPHTTPserver with SSL
« Reply #6 on: May 04, 2022, 03:31:30 pm »
See the example simpleserver in trunk's fpcsrc/fpc-3.3.1/packages/fcl-web/examples/simpleserver
that example is not working in Linux, also not on windows 10, there is some other examples or more docs ?
So for what platform is this example working?

"Is not working" isn't really a problem description.

Here is some more information. You could try to write your own (or explain more clearly what exactly "isn't working").
https://wiki.lazarus.freepascal.org/fpWeb_Tutorial

it has been tested on Linux Mint, but as I said I got an error(connection reset ) from the browser while navigating to the server, tried to debug that with OpenSSL and i think that's due to failure to generate a self-signed cert while running or compiling. i think i will try to generate that manually first then inspect what's the reason for that

fpc2pas

  • New Member
  • *
  • Posts: 34
Re: FPHTTPserver with SSL
« Reply #7 on: May 04, 2022, 03:49:01 pm »
I think recently there is an SSL support for fphttpserver, but I think the examples provided not really working, and tried to port something similar but also fails to generate or assign a self-signed cert, any ideas or demos?

I had similar problem, but now it works. I'm using synapse for ssl socket, just include opensslsockets into your lpr if you use synapse.
Also, I'm using self signed certs for testing and it works. Of course, eg. curl refuse to establish such connection because of self signed certificates, but with --insecure option it works ok.
Note: I've generated self signed certificates by using openssl under linux.

EDIT:  This is how I've setted up https server certificates:
    Application.UseSSL := True;
    Application.CertificateData.HostName := MyWebServerConfig.CertificateHostName;
    Application.CertificateData.KeyPassword:='';
    Application.CertificateData.PrivateKey.FileName := MyWebServerConfig.CertificatePrivateKey;
    Application.CertificateData.Certificate.FileName := MyWebServerConfig.CertificateCertificate;

yup that's worked for me i just created the cert manually and filled it, much thanks

 

TinyPortal © 2005-2018