LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 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 x509 | 5 package x509 |
6 | 6 |
7 import ( | 7 import ( |
8 "os" | 8 "os" |
9 "strings" | 9 "strings" |
10 "time" | 10 "time" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 195 } |
196 | 196 |
197 return | 197 return |
198 } | 198 } |
199 | 199 |
200 func matchHostnames(pattern, host string) bool { | 200 func matchHostnames(pattern, host string) bool { |
201 if len(pattern) == 0 || len(host) == 0 { | 201 if len(pattern) == 0 || len(host) == 0 { |
202 return false | 202 return false |
203 } | 203 } |
204 | 204 |
205 » patternParts := strings.Split(pattern, ".", -1) | 205 » patternParts := strings.Split(pattern, ".") |
206 » hostParts := strings.Split(host, ".", -1) | 206 » hostParts := strings.Split(host, ".") |
207 | 207 |
208 if len(patternParts) != len(hostParts) { | 208 if len(patternParts) != len(hostParts) { |
209 return false | 209 return false |
210 } | 210 } |
211 | 211 |
212 for i, patternPart := range patternParts { | 212 for i, patternPart := range patternParts { |
213 if patternPart == "*" { | 213 if patternPart == "*" { |
214 continue | 214 continue |
215 } | 215 } |
216 if patternPart != hostParts[i] { | 216 if patternPart != hostParts[i] { |
(...skipping 13 matching lines...) Expand all Loading... |
230 return nil | 230 return nil |
231 } | 231 } |
232 } | 232 } |
233 // If Subject Alt Name is given, we ignore the common name. | 233 // If Subject Alt Name is given, we ignore the common name. |
234 } else if matchHostnames(c.Subject.CommonName, h) { | 234 } else if matchHostnames(c.Subject.CommonName, h) { |
235 return nil | 235 return nil |
236 } | 236 } |
237 | 237 |
238 return HostnameError{c, h} | 238 return HostnameError{c, h} |
239 } | 239 } |
LEFT | RIGHT |