copy the ServerName from the tls.Config to the mint.Config

This commit is contained in:
Marten Seemann
2018-01-11 22:43:17 +07:00
parent f33243fb41
commit 5283cc5ff4
2 changed files with 8 additions and 0 deletions

View File

@@ -77,6 +77,7 @@ func tlsToMintConfig(tlsConf *tls.Config, pers protocol.Perspective) (*mint.Conf
},
}
if tlsConf != nil {
mconf.ServerName = tlsConf.ServerName
mconf.Certificates = make([]*mint.Certificate, len(tlsConf.Certificates))
for i, certChain := range tlsConf.Certificates {
mconf.Certificates[i] = &mint.Certificate{

View File

@@ -42,6 +42,13 @@ var _ = Describe("Packing and unpacking Initial packets", func() {
Expect(mintConf.NonBlocking).To(BeTrue())
})
It("sets the server name", func() {
conf := &tls.Config{ServerName: "www.example.com"}
mintConf, err := tlsToMintConfig(conf, protocol.PerspectiveClient)
Expect(err).ToNot(HaveOccurred())
Expect(mintConf.ServerName).To(Equal("www.example.com"))
})
It("sets the certificate chain", func() {
tlsConf := testdata.GetTLSConfig()
mintConf, err := tlsToMintConfig(tlsConf, protocol.PerspectiveClient)