How do I enable HTTPS via Snap Server?

Is there a simple example of enabling HTTPS on a Snap server? I am not into OpenSsl and using it using Snap. Thanks to

+3


source to share


1 answer


JP Moresmau showed you how to enable it from the command line, but doing the same programmatically is just as easy. The function that runs Snap "main loop" takes a configuration parameter as its first argument, as you see in this snippet of documentation . You can simply call defaultConfig

from the Snap.Http.Server.Config module and then call setSSLPort

, setCert

and setSSLKey

on the topic. Then you can pass this new configuration httpServe

in as the first argument. If you have used snap init

, you can find all the relevant codes in src/Main.hs

.

As you can see here , the default configuration is generated from the command line using description . Therefore, the change defaultConfig

is exactly the same as passing command line arguments.



What I find a little odd is that there is no defaultSSLConfig

one that generates a self-signed certificate so you can try SSL quickly. Also, this is an odd certificate and keys are of type FilePath

. Maybe this is a good request to get the Snap team for review?

+2


source







All Articles