Hey everyone working on this package, thanks for your work as I feel like I am already there and close to using it fully for my task:
I have successfully made a socket connection using a ca file:
err = ctx.LoadVerifyLocations("file.cer", "")
My Dial is not erroring:
conn, err := openssl.Dial("tcp", addr, ctx, openssl.InsecureSkipHostVerification)
My writes are not erroring:
log.Println("writing")
log.Println(obj.conn.Write([]byte("{}")))
2022/08/18 17:16:42 writing
2022/08/18 17:16:42 118 <nil>
I setup a reader go func obj.conn is just the returned *openssl.Conn and it blocks until my read deadline is met obj.conn.SetReadDeadline(time.Now().Add(time.Second * 10))
at the point where a reader times out, I usually reconnect on the socket (I also tried a longer read timeout thinking maybe the packets would come through the network):
go func() {
for {
result := make([]byte, 1024)
length, err := obj.conn.Read(result)
if err != nil {
log.Println("Reader Err: " + err.Error())
obj.Connect(addr)
return
}
log.Println("Result", result[:length])
}
}()
I also thought that perhaps openssl is wanting me to setup a read immediately after a write kind of like udp might. But that didnt work either.
When I setup openssl s_client -connect IP:PORT -CAfile file.cer
and make a connection and write the same JSON to the socket I am working with, I immediately see a response which I am expecting would come through in my reader goroutine. Is there something s_client does which is different than how this library might read data from network packets coming back from the server?
I am no expert in openssl and this library, but I have lots of experience in tcp, telnet, udp, websocket, ssh and other network protocols. This is my first secure driver over tls and openssl and I was thinking this would work like tcp does in receiving responses from the network responses.
Does anyone have any ideas with the differences between openssl's s_client and this libraries bindings/usage and how the response data might be different?