A similar issue had been opened at #25807 but it was retracted without any explanation so I would like to bring this into light again as it is a pain for VPN solutions written in Go.
TLS Hello messages are allowed to have custom extensions therefore an application can ask the underlying TLS library to add arbitrary data. As we really need this we have ended up patching Go so I can actually present a working solution to give a general idea of what I mean and how it can play out:
- A new type in
crypto/tls/common.go
type HelloExtension struct {
Type uint16
Data []uint8
}
- Add
HelloExtensions []HelloExtension in the Config struct and copy in the Clone() func
- Add
[]HelloExtension to clientHelloMsg (client case)
- Add to the marshal
if len(m.helloExtensions) > 0 {
for _, e := range m.helloExtensions {
b.AddUint16(e.Type)
b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) {
b.AddBytes(e.Data)
})
}
}
- Applications can then create extensions with simply
tls.HelloExtension{ Type: XXX, Data: YYY} and append them in the tls.Config.HelloExtensions
A similar issue had been opened at #25807 but it was retracted without any explanation so I would like to bring this into light again as it is a pain for VPN solutions written in Go.
TLS Hello messages are allowed to have custom extensions therefore an application can ask the underlying TLS library to add arbitrary data. As we really need this we have ended up patching Go so I can actually present a working solution to give a general idea of what I mean and how it can play out:
crypto/tls/common.goHelloExtensions []HelloExtensionin theConfig structand copy in theClone()func[]HelloExtensiontoclientHelloMsg(client case)tls.HelloExtension{ Type: XXX, Data: YYY}and append them in thetls.Config.HelloExtensions