<div dir="ltr"><div>Hello,<br><br>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.<br>

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

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

                 contextHookSetLogging ctx logging<br>                 handshake ctx<br><br></div>The rest of it would probably too much to fit into an email, so I am linking it from here: <a href="http://lpaste.net/102014">http://lpaste.net/102014</a><br>

<br>When I run it, the client fails to parse the handshake:<br>Error_Packet_Parsing "Failed reading: invalid header type: 1\nFrom:\theader\n\n"<br><br>Whereas the server says 'server hello done' right before it receives the alert from the client.<br>

<br>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?<br><br>Thanks a lot!<br>

<br>- Reto<br><div><br></div></div>