Skip to content

proposal: crypto/tls: custom TLS extensions support #51497

Description

@kosmas-valianos

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:

  1. A new type in crypto/tls/common.go
type HelloExtension struct {
	Type uint16
	Data []uint8
}
  1. Add HelloExtensions []HelloExtension in the Config struct and copy in the Clone() func
  2. Add []HelloExtension to clientHelloMsg (client case)
  3. 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)
					})
				}
			}
  1. Applications can then create extensions with simply tls.HelloExtension{ Type: XXX, Data: YYY} and append them in the tls.Config.HelloExtensions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions