Haskell Warp / Wai and HTTPS - how to make them work?

I have a basic hello-world application in Haskell Servant and Warp. This is not real code, but for simplicity, let me say that I use it:

import Network.Wai import Network.Wai.Handler.Warp import Servant personAPI :: Proxy PersonAPI personAPI = Proxy server :: Server PersonAPI server = return people app :: Application app = serve personAPI server serveApp :: IO () serveApp = run 80 app 

It works fine on the server. With http.

I do not use nginx or apache, I start it as it is and at the moment this is great for me.

But with https it will not load the page. I installed the https certificate, but I realized that I had to configure warp / wai somehow to use it, because by default it would not use it. There is a lack of information about this - warp / wai and SSL, I did not find anything. Can anyone help me?

+6
source share
1 answer

I think the easiest way is to use the warp-tls library - install the certificate files in TLSSettings (I would try TLSSettings ) and use runTLS instead of run :

 serveApp :: IO () serveApp = do let tls = tlsSettings "pathToCert" "pathToKey" runTLS tls (setPort 443 defaultSettings) app 
+7
source

All Articles