Skip to content
Browse files

Sniff TLS via 0x16 (#60)

  • Loading branch information...
1 parent 3799c68 commit 1dbf88f237d446863e62fa2300989ea537661cd7 @snoyberg snoyberg committed
Showing with 6 additions and 6 deletions.
  1. +6 −6 warp-tls/Network/Wai/Handler/WarpTLS.hs
View
12 warp-tls/Network/Wai/Handler/WarpTLS.hs
@@ -61,13 +61,8 @@ runTLS tset set app = do
(fromClient'', bs) <- fromClient' C.$$++ sink
I.writeIORef ifromClient fromClient''
return bs
- if maybe False (B.all (\w -> w < 127 && w > 8) . B.take 5) firstBS
+ if maybe False ((== 0x16) . fst) (firstBS >>= B.uncons)
then do
- let conn = (socketConnection s)
- { connRecv = getNext $ fmap (fromMaybe B.empty) C.await
- }
- return (conn, sa)
- else do
gen <- newGenIO
ctx <- TLS.serverWith
params
@@ -89,6 +84,11 @@ runTLS tset set app = do
, connRecv = TLS.recvData ctx
}
return (conn, sa)
+ else do
+ let conn = (socketConnection s)
+ { connRecv = getNext $ fmap (fromMaybe B.empty) C.await
+ }
+ return (conn, sa)
-- taken from stunnel example in tls-extra
ciphers :: [TLS.Cipher]

0 comments on commit 1dbf88f

Please sign in to comment.
Something went wrong with that request. Please try again.