on master help sign in
Sniff TLS via 0x16 (#60)
1dbf88fMichael Snoyman
warp-tls/Network/Wai/Handler/WarpTLS.hs+6−6
@@ -61,13 +61,8 @@ runTLS tset set app = do
61 (fromClient'', bs) <- fromClient' C.$$++ sink
61 (fromClient'', bs) <- fromClient' C.$$++ sink
62 I.writeIORef ifromClient fromClient''
62 I.writeIORef ifromClient fromClient''
63 return bs
63 return bs
64− if maybe False (B.all (\w -> w < 127 && w > 8) . B.take 5) firstBS
64+ if maybe False ((== 0x16) . fst) (firstBS >>= B.uncons)
65 then do
65 then do
66− let conn = (socketConnection s)
67− { connRecv = getNext $ fmap (fromMaybe B.empty) C.await
68− }
69− return (conn, sa)
70− else do
71 gen <- newGenIO
66 gen <- newGenIO
72 ctx <- TLS.serverWith
67 ctx <- TLS.serverWith
73 params
68 params
@@ -89,6 +84,11 @@ runTLS tset set app = do
89 , connRecv = TLS.recvData ctx
84 , connRecv = TLS.recvData ctx
90 }
85 }
91 return (conn, sa)
86 return (conn, sa)
87+ else do
88+ let conn = (socketConnection s)
89+ { connRecv = getNext $ fmap (fromMaybe B.empty) C.await
90+ }
91+ return (conn, sa)
92
92
93-- taken from stunnel example in tls-extra
93-- taken from stunnel example in tls-extra
94ciphers :: [TLS.Cipher]
94ciphers :: [TLS.Cipher]