make runConnection take a certificate as a parameter

This commit is contained in:
Jonathan Lamothe 2021-11-10 14:06:20 -05:00
parent a15abeaa1f
commit 17f1eba583
2 changed files with 6 additions and 2 deletions

View File

@ -48,7 +48,7 @@ import qualified Data.ByteString as BS
import Data.ByteString.Builder (charUtf8, stringUtf8, toLazyByteString) import Data.ByteString.Builder (charUtf8, stringUtf8, toLazyByteString)
import qualified Data.ByteString.Lazy as BSL import qualified Data.ByteString.Lazy as BSL
import Data.Char (chr, ord, toLower) import Data.Char (chr, ord, toLower)
import Data.IORef (IORef, newIORef, writeIORef) import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Data.List (find, intercalate) import Data.List (find, intercalate)
import Data.Maybe (fromJust) import Data.Maybe (fromJust)
import qualified Data.Text as T import qualified Data.Text as T
@ -183,7 +183,8 @@ listenLoop sock params handler = do
let params' = adjustServerParams certRef params let params' = adjustServerParams certRef params
try (accept params' sock) >>= \case try (accept params' sock) >>= \case
Left (_ :: IOException) -> return () Left (_ :: IOException) -> return ()
Right conn -> void $ forkIO $ runConnection conn handler Right conn -> void $ forkIO $
readIORef certRef >>= runConnection conn handler
listenLoop sock params handler listenLoop sock params handler
adjustServerParams adjustServerParams

View File

@ -34,6 +34,7 @@ module Network.GemServ.Internal (
runConnection runConnection
) where ) where
import Data.X509 (Certificate)
import System.IO.Streams.TLS (TLSConnection) import System.IO.Streams.TLS (TLSConnection)
import Network.GemServ.Types import Network.GemServ.Types
@ -45,6 +46,8 @@ runConnection
-- ^ The connection -- ^ The connection
-> GemHandler -> GemHandler
-- ^ The handler that produces the response -- ^ The handler that produces the response
-> Maybe Certificate
-- ^ The client certificate (if available)
-> IO () -> IO ()
runConnection = undefined runConnection = undefined