eclipse-paho / paho.mqtt.golang

Other
2.77k stars 534 forks source link

Looking for a way to print the negotiated cipher suite of TLS 1.2 connection #631

Closed intersynct closed 1 year ago

intersynct commented 1 year ago

I am using the mqtt package to test against AWS IoT and everything works fine.

My only need is to print the cipher suite that is in use for the TLS 1.2 connection, so I can see what is used when I specify specific cypher suites in the config, or do not specify which cipher suites to use.

The net.Conn struct has a cipherSuite field that may contain the uint16 value of the cipher suite in use for the connection. net.Conn is returned by the attemptConnection function.

Should I just clone and print after the attemptConnection call? I don't mind if the connection gets corrupted as long as I can print the cipher suite that was in use at the time.

Any thoughts on ways to approach this?

MattBrittan commented 1 year ago

As per the readme:

if you have a general question please see the resources in the more information section for help.

As I'm responding anyway I'd point you towards SetCustomOpenConnectionFn as that will give you complete control over the connection process (you just need to return a net.Conn).

intersynct commented 1 year ago

Sorry for the slip-up. I have read the section, noted it and will adhere to it going forward.

Also, thank you very much for your helpful response.

Cheers