[Haskell-cafe] TLS Handshake fails with 'invalid header type: 1\nFrom:\theader\n\n"'

Reto Hablützel rethab at rethab.ch
Sun Mar 30 16:02:47 UTC 2014


Hello,

I'm trying to a establish a TLS connection with the hs-tls library. I got
most of the code from the Stunnel.hs, but what I am trying do here is to be
able to pass either 'Client' or 'Server' as argument and then, depending on
which one it is, act as either one in the handshake.

This is the code, that tries to make the handshake:
client :: Socket -> IO ()
client sock = do addr <- sockaddr
                 _ <- connect sock addr
                 ctx <- myCCtx sock
                 contextHookSetLogging ctx logging
                 handshake ctx

server :: Socket -> IO ()
server sock = do sockaddr >>= bind sock
                 listen sock 1
                 (peer, _) <- accept sock
                 ctx <- mySCtx peer
                 contextHookSetLogging ctx logging
                 handshake ctx

The rest of it would probably too much to fit into an email, so I am
linking it from here: http://lpaste.net/102014

When I run it, the client fails to parse the handshake:
Error_Packet_Parsing "Failed reading: invalid header type:
1\nFrom:\theader\n\n"

Whereas the server says 'server hello done' right before it receives the
alert from the client.

How can this happen? That 'From:\theader...' doesn't even exist as a string
in the hs-tls library.. Is there anywhere an example for the hs-tls library
with a client as well as a server?

Thanks a lot!

- Reto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140330/684e403a/attachment.html>


More information about the Haskell-Cafe mailing list