Skip to content

Commit

Permalink
set the correct HTTP/3 ALPN for QUIC v2
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 26, 2022
1 parent b2deece commit c5ee496
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 3 additions & 5 deletions http3/server.go
Expand Up @@ -44,7 +44,7 @@ const (
)

func versionToALPN(v protocol.VersionNumber) string {
if v == protocol.Version1 {
if v == protocol.Version1 || v == protocol.Version2 {
return nextProtoH3
}
if v == protocol.VersionTLS || v == protocol.VersionDraft29 {
Expand All @@ -63,11 +63,9 @@ func ConfigureTLSConfig(tlsConf *tls.Config) *tls.Config {
return &tls.Config{
GetConfigForClient: func(ch *tls.ClientHelloInfo) (*tls.Config, error) {
// determine the ALPN from the QUIC version used
proto := nextProtoH3Draft29
proto := nextProtoH3
if qconn, ok := ch.Conn.(handshake.ConnWithVersion); ok {
if qconn.GetQUICVersion() == protocol.Version1 {
proto = nextProtoH3
}
proto = versionToALPN(qconn.GetQUICVersion())
}
config := tlsConf
if tlsConf.GetConfigForClient != nil {
Expand Down
10 changes: 5 additions & 5 deletions http3/server_test.go
Expand Up @@ -819,23 +819,23 @@ var _ = Describe("Server", func() {
ch = &tls.ClientHelloInfo{}
})

It("advertises draft by default", func() {
It("advertises v1 by default", func() {
tlsConf = ConfigureTLSConfig(tlsConf)
Expect(tlsConf.GetConfigForClient).NotTo(BeNil())

config, err := tlsConf.GetConfigForClient(ch)
Expect(err).NotTo(HaveOccurred())
Expect(config.NextProtos).To(Equal([]string{nextProtoH3Draft29}))
Expect(config.NextProtos).To(Equal([]string{nextProtoH3}))
})

It("advertises h3 for quic version 1", func() {
It("advertises h3-29 for draft-29", func() {
tlsConf = ConfigureTLSConfig(tlsConf)
Expect(tlsConf.GetConfigForClient).NotTo(BeNil())

ch.Conn = newMockConn(protocol.Version1)
ch.Conn = newMockConn(protocol.VersionDraft29)
config, err := tlsConf.GetConfigForClient(ch)
Expect(err).NotTo(HaveOccurred())
Expect(config.NextProtos).To(Equal([]string{nextProtoH3}))
Expect(config.NextProtos).To(Equal([]string{nextProtoH3Draft29}))
})
})

Expand Down

0 comments on commit c5ee496

Please sign in to comment.