on master help sign in
tls 1.0
commit392d5a71ec91118ae45e8dda629a99853db5b434 authorMichael Snoyman <michael@snoyman.com> dateWed 24 Oct 2012, 07:50 (14 years ago) parent998d8cc
2 files changed+28−4
warp-tls/Network/Wai/Handler/WarpTLS.hs+24 warp-tls/warp-tls.cabal+4−4
warp-tls/Network/Wai/Handler/WarpTLS.hs+24
@@ -1,5 +1,6 @@
11{-# LANGUAGE OverloadedStrings #-}
22{-# LANGUAGE RankNTypes #-}
3+{-# LANGUAGE CPP #-}
34module Network.Wai.Handler.WarpTLS
45 ( TLSSettings (..)
56 , runTLS
@@ -38,12 +39,23 @@ runTLSSocket :: TLSSettings -> Settings -> Socket -> Application -> IO ()
3839runTLSSocket tset set sock app = do
3940 certs <- readCertificates $ certFile tset
4041 pk <- readPrivateKey $ keyFile tset
42+#if MIN_VERSION_tls(1, 0, 0)
43+ let params =
44+ TLS.updateServerParams
45+ (\sp -> sp { TLS.serverWantClientCert = False }) $
46+ TLS.defaultParamsServer
47+ { TLS.pAllowedVersions = [TLS.SSL3,TLS.TLS10,TLS.TLS11,TLS.TLS12]
48+ , TLS.pCiphers = ciphers
49+ , TLS.pCertificates = zip certs $ (Just pk):repeat Nothing
50+ }
51+#else
4152 let params = TLS.defaultParams
4253 { TLS.pWantClientCert = False
4354 , TLS.pAllowedVersions = [TLS.SSL3,TLS.TLS10,TLS.TLS11,TLS.TLS12]
4455 , TLS.pCiphers = ciphers
4556 , TLS.pCertificates = zip certs $ (Just pk):repeat Nothing
4657 }
58+#endif
4759 runSettingsConnection set (getter params sock) app
4860 where
4961 retry :: Socket -> TLS.TLSParams -> Socket -> SomeException -> IO (Connection, SockAddr)
@@ -63,6 +75,17 @@ runTLSSocket tset set sock app = do
6375 if maybe False ((== 0x16) . fst) (firstBS >>= B.uncons)
6476 then do
6577 gen <- newGenIO
78+#if MIN_VERSION_tls(1, 0, 0)
79+ ctx <- TLS.contextNew
80+ TLS.Backend
81+ { TLS.backendFlush = return ()
82+ , TLS.backendClose = return ()
83+ , TLS.backendSend = \bs -> C.yield bs C.$$ toClient
84+ , TLS.backendRecv = getNext . takeMost
85+ }
86+ params
87+ (gen :: SystemRandom)
88+#else
6689 ctx <- TLS.serverWith
6790 params
6891 (gen :: SystemRandom)
@@ -70,6 +93,7 @@ runTLSSocket tset set sock app = do
7093 (return ()) -- flush
7194 (\bs -> C.yield bs C.$$ toClient)
7295 (getNext . takeMost)
96+#endif
7397 TLS.handshake ctx
7498 let conn = Connection
7599 { connSendMany = TLS.sendData ctx . L.fromChunks
warp-tls/warp-tls.cabal+4−4
@@ -1,5 +1,5 @@
11Name: warp-tls
2−Version: 1.3.2
2+Version: 1.3.3
33Synopsis: SSL support for Warp via the TLS package
44License: MIT
55License-file: LICENSE
@@ -20,11 +20,11 @@ Library
2020 , transformers >= 0.2 && < 0.4
2121 , conduit >= 0.5 && < 0.6
2222 , network-conduit >= 0.5 && < 0.7
23− , certificate >= 1.2 && < 1.3
23+ , certificate >= 1.2 && < 1.4
2424 , pem >= 0.1 && < 0.2
2525 , cryptocipher >= 0.3 && < 0.4
26− , tls-extra >= 0.4.5 && < 0.5
27− , tls >= 0.9.6 && < 0.10
26+ , tls-extra >= 0.4.5 && < 0.6
27+ , tls >= 0.9.6 && < 1.1
2828 , crypto-api >= 0.8 && < 0.11
2929 , network >= 2.2.1
3030 Exposed-modules: Network.Wai.Handler.WarpTLS