copy RootCAs to mint config (#1291)

This commit is contained in:
jared2501
2018-04-15 01:59:02 -07:00
committed by Marten Seemann
parent 4035836ff0
commit ef286afa3c
2 changed files with 4 additions and 0 deletions

View File

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

View File

@@ -55,7 +55,9 @@ var _ = Describe("Packing and unpacking Initial packets", func() {
It("copies values from the tls.Config", func() {
verifyErr := errors.New("test err")
certPool := &x509.CertPool{}
tlsConf := &tls.Config{
RootCAs: certPool,
ServerName: "www.example.com",
InsecureSkipVerify: true,
VerifyPeerCertificate: func(_ [][]byte, _ [][]*x509.Certificate) error {
@@ -64,6 +66,7 @@ var _ = Describe("Packing and unpacking Initial packets", func() {
}
mintConf, err := tlsToMintConfig(tlsConf, protocol.PerspectiveClient)
Expect(err).ToNot(HaveOccurred())
Expect(mintConf.RootCAs).To(Equal(certPool))
Expect(mintConf.ServerName).To(Equal("www.example.com"))
Expect(mintConf.InsecureSkipVerify).To(BeTrue())
Expect(mintConf.VerifyPeerCertificate(nil, nil)).To(MatchError(verifyErr))