forked from quic-go/quic-go
reject a tls.Config without NextProtos for listening
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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}})
|
||||
|
||||
Reference in New Issue
Block a user