Skip to content

Commit

Permalink
Use kazu's version of wai and hs-tls
Browse files Browse the repository at this point in the history
See stack.yaml for the commits.
  • Loading branch information
eyeinsky committed Dec 15, 2019
1 parent eee46cf commit 05d4512
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import Control.Monad
main :: IO ()
main = WarpTLS.runTLS tlsSettings' Warp.defaultSettings handler

handler :: WarpTLS.TLSAppInfo -> Wai.Application
handler tlsInfo req resp = do
let ioRef = fromJust tlsInfo -- Always Just when using runTLS
maybeChain <- readIORef ioRef
handler :: Wai.Application
handler req resp = do
let maybeChain = Warp.clientCertificate req
case maybeChain of
Just (X509.CertificateChain (cert : _)) -> do
putStrLn "Got cert:"
Expand All @@ -37,8 +36,8 @@ tlsSettings' :: WarpTLS.TLSSettings
tlsSettings' = (WarpTLS.tlsSettings "cert_server_cert.pem" "cert_server_key.pem")
{ WarpTLS.tlsWantClientCert = True
, WarpTLS.tlsServerHooks = def
{ Network.TLS.onClientCertificate = \ chain ioref -> do
atomicWriteIORef ioref $ Just chain
{ Network.TLS.onClientCertificate = \ chain -> do
print "onClientCertificate"
return Network.TLS.CertificateUsageAccept
}
}
Expand Down
8 changes: 4 additions & 4 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ packages:
- .

extra-deps:
- github: eyeinsky/wai
commit: 73b19ba3515551b40d63a034f543993944071867
- github: kazu-yamamoto/wai
commit: d993730c5c3c72321da047a384e9aa41869c2da7
subdirs:
- warp
- warp-tls
- github: eyeinsky/hs-tls
commit: 44547ddc250616b1403b765ff5a4cf5d74361225
- github: kazu-yamamoto/hs-tls
commit: 5926aeb47052bf1db651af3988dcfbf1517e891c
subdirs:
- core
- session
Expand Down

0 comments on commit 05d4512

Please sign in to comment.