ourway / webfsd

A simple HTTP server for mostly static content written in C
GNU General Public License v2.0
90 stars 18 forks source link

How can I enable the optional SSL support? #14

Open NautillusSs opened 1 year ago

NautillusSs commented 1 year ago

Trying to understand the GNU make file and the USE_SSL variable. What sets it to true? I looked around in your code and website but cannot figure it out. Does it check for the local presence of the openssl header? If I were to create a Dockerfile like https://github.com/ourway/docker-webfsd/blob/main/Dockerfile should I simply install the openssl package?

Thank you for any help! Great little server. It's the only one I've found so far that supports byte ranges and works out of the box for streaming videos.

PierceNg commented 11 months ago

Make it:

$ make -e USE_SSL=yes -e USE_SENDFILE=yes

Run it:

$ ./webfsd -F -4 -p 8443 -S -C ssl/server.pem
SSL cert load error [error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small]
SSL privkey load error [error:00000000:lib(0):func(0):reason(0)]

Ok the bundled server certificate was generated in 2002 with a 1024-bit RSA key. Too small for today's Internet. To generate your own self-signed certificate:

$ openssl genrsa -out selfsigned.key 4096
<blah blah>
$ openssl req -key selfsigned.key -new -out selfsigned.csr
<blah blah>
$ openssl x509 -req -days 365 -in selfsigned.csr -signkey selfsigned.key -out selfsigned.crt
<blah blah>
$ rm selfsigned.csr
$ cat selfsigned.crt selfsigned.key > selfsigned.cert_key.pem

Run:

$ ./webfsd -F -4 -p 8443 -S -C selfsigned.cert_key.pem
38github commented 8 months ago

Really helpful information here. Can this be added to the documentation/man, please?