LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package tls | 5 package tls |
6 | 6 |
7 import ( | 7 import ( |
8 "crypto" | 8 "crypto" |
9 "crypto/rsa" | 9 "crypto/rsa" |
10 "crypto/subtle" | 10 "crypto/subtle" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 certs := make([]*x509.Certificate, len(certMsg.certificates)) | 90 certs := make([]*x509.Certificate, len(certMsg.certificates)) |
91 for i, asn1Data := range certMsg.certificates { | 91 for i, asn1Data := range certMsg.certificates { |
92 cert, err := x509.ParseCertificate(asn1Data) | 92 cert, err := x509.ParseCertificate(asn1Data) |
93 if err != nil { | 93 if err != nil { |
94 c.sendAlert(alertBadCertificate) | 94 c.sendAlert(alertBadCertificate) |
95 return os.NewError("failed to parse certificate from ser
ver: " + err.String()) | 95 return os.NewError("failed to parse certificate from ser
ver: " + err.String()) |
96 } | 96 } |
97 certs[i] = cert | 97 certs[i] = cert |
98 } | 98 } |
99 | 99 |
100 » if c.config.InsecureSkipVerify == false { | 100 » if !c.config.InsecureSkipVerify { |
101 opts := x509.VerifyOptions{ | 101 opts := x509.VerifyOptions{ |
102 Roots: c.config.rootCAs(), | 102 Roots: c.config.rootCAs(), |
103 CurrentTime: c.config.time(), | 103 CurrentTime: c.config.time(), |
104 DNSName: c.config.ServerName, | 104 DNSName: c.config.ServerName, |
105 Intermediates: x509.NewCertPool(), | 105 Intermediates: x509.NewCertPool(), |
106 } | 106 } |
107 | 107 |
108 for i, cert := range certs { | 108 for i, cert := range certs { |
109 if i == 0 { | 109 if i == 0 { |
110 continue | 110 continue |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 for _, s := range serverProtos { | 304 for _, s := range serverProtos { |
305 for _, c := range clientProtos { | 305 for _, c := range clientProtos { |
306 if s == c { | 306 if s == c { |
307 return s, false | 307 return s, false |
308 } | 308 } |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 return clientProtos[0], true | 312 return clientProtos[0], true |
313 } | 313 } |
LEFT | RIGHT |