diff --git a/server.go b/server.go index eb780ac68..bcc8de6b2 100644 --- a/server.go +++ b/server.go @@ -141,6 +141,9 @@ func listen(conn net.PacketConn, tlsConf *tls.Config, config *Config) (*server, if tlsConf == nil || len(tlsConf.Certificates) == 0 { return nil, errors.New("quic: Certificates not set in tls.Config") } + if len(tlsConf.NextProtos) == 0 { + return nil, errors.New("quic: NextProtos not set in tls.Config") + } config = populateServerConfig(config) for _, v := range config.Versions { if !protocol.IsValidVersion(v) { diff --git a/server_test.go b/server_test.go index 00c0c78df..a8a26da59 100644 --- a/server_test.go +++ b/server_test.go @@ -42,6 +42,7 @@ var _ = Describe("Server", func() { conn = newMockPacketConn() conn.addr = &net.UDPAddr{} tlsConf = testdata.GetTLSConfig() + tlsConf.NextProtos = []string{"proto1"} }) It("errors when no tls.Config is given", func() { @@ -56,6 +57,13 @@ var _ = Describe("Server", func() { Expect(err.Error()).To(ContainSubstring("quic: Certificates not set in tls.Config")) }) + It("errors when NextProtos is not set in the tls.Config", func() { + tlsConf.NextProtos = nil + _, err := ListenAddr("localhost:0", tlsConf, nil) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("quic: NextProtos not set in tls.Config")) + }) + It("errors when the Config contains an invalid version", func() { version := protocol.VersionNumber(0x1234) _, err := Listen(nil, tlsConf, &Config{Versions: []protocol.VersionNumber{version}})