I am new in the go programming language and I am crafting Ethernet frames myself with the "gopacket" library of Google. I have successfully implemented basic TCP functionality in userspace for educational purposes and I can successfully initiate 3-way-handshakes with Webservers.
Now I would like initiate a TLS handshake on top of this and my problem is that all existing TLS libraries in go use sockets or the Conn interface to initiate TLS connections. Is there some easy way to craft a raw TLS Client Hello message in go that I could use as a payload for my TCP segments?
I do not want to implement fancy things like data transmissions or whatever. It is enough if I would be able to send a Client-Hello to a server and see what the reply looks like before ending the connection.
Thank you for any advices you may have for a newbie in go. :-)
I'd say one way would be to mock a Conn
you feed to the TLS library so you can intercept the calls and forward/relay them or... you do this the manual way by looking at for example handshake_client.go and copy whatever you need (the methods it contains are sadly private only).
Personally I'd probably go for the Conn
approach.
I tried both ways but they were not successfull.
In the end I have chosen the most ugly solution but a one working out for my simple scenario: I captured a TLS Client Hello via Wireshark, and hard coded it in go as a byte array in hex.