Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1487)

Side by Side Diff: net/base/transport_security_state_static_generate.go

Issue 10411075: net: add certificate pins for tor2web.org (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This program converts the information in 5 // This program converts the information in
6 // transport_security_state_static.json and 6 // transport_security_state_static.json and
7 // transport_security_state_static.certs into 7 // transport_security_state_static.certs into
8 // transport_security_state_static.h. The input files contain information about 8 // transport_security_state_static.h. The input files contain information about
9 // public key pinning and HTTPS-only sites that is compiled into Chromium. 9 // public key pinning and HTTPS-only sites that is compiled into Chromium.
10 10
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // given CN. 276 // given CN.
277 func matchNames(name, v string) error { 277 func matchNames(name, v string) error {
278 words := strings.Split(name, " ") 278 words := strings.Split(name, " ")
279 if len(words) == 0 { 279 if len(words) == 0 {
280 return errors.New("no words in certificate name") 280 return errors.New("no words in certificate name")
281 } 281 }
282 firstWord := words[0] 282 firstWord := words[0]
283 if strings.HasSuffix(firstWord, ",") { 283 if strings.HasSuffix(firstWord, ",") {
284 firstWord = firstWord[:len(firstWord)-1] 284 firstWord = firstWord[:len(firstWord)-1]
285 } 285 }
286 if strings.HasPrefix(firstWord, "*.") {
287 firstWord = firstWord[2:]
288 }
286 if pos := strings.Index(firstWord, "."); pos != -1 { 289 if pos := strings.Index(firstWord, "."); pos != -1 {
287 firstWord = firstWord[:pos] 290 firstWord = firstWord[:pos]
288 } 291 }
289 if pos := strings.Index(firstWord, "-"); pos != -1 { 292 if pos := strings.Index(firstWord, "-"); pos != -1 {
290 firstWord = firstWord[:pos] 293 firstWord = firstWord[:pos]
291 } 294 }
292 » if !strings.HasPrefix(v, firstWord) { 295 » if len(firstWord) == 0 {
palmer 2012/05/22 19:24:46 Looks like inconsistent whitespace here.
agl 2012/05/23 19:29:25 That's just how codereview is showing it. I've run
296 » » return errors.New("first word of certificate name is empty")
297 » }
298 » firstWord = strings.ToLower(firstWord)
299 » lowerV := strings.ToLower(v)
300 » if !strings.HasPrefix(lowerV, firstWord) {
293 return errors.New("the first word of the certificate name isn't a prefix of the variable name") 301 return errors.New("the first word of the certificate name isn't a prefix of the variable name")
294 } 302 }
295 303
296 for i, word := range words { 304 for i, word := range words {
297 if word == "Class" && i+1 < len(words) { 305 if word == "Class" && i+1 < len(words) {
298 if strings.Index(v, word+words[i+1]) == -1 { 306 if strings.Index(v, word+words[i+1]) == -1 {
299 return errors.New("class specification doesn't a ppear in the variable name") 307 return errors.New("class specification doesn't a ppear in the variable name")
300 } 308 }
301 } else if len(word) == 1 && word[0] >= '0' && word[0] <= '9' { 309 } else if len(word) == 1 && word[0] >= '0' && word[0] <= '9' {
302 if strings.Index(v, word) == -1 { 310 if strings.Index(v, word) == -1 {
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 writeHSTSEntry(out, entry) 546 writeHSTSEntry(out, entry)
539 } 547 }
540 548
541 out.WriteString(`}; 549 out.WriteString(`};
542 static const size_t kNumPreloadedSNISTS = ARRAYSIZE_UNSAFE(kPreloadedSNISTS); 550 static const size_t kNumPreloadedSNISTS = ARRAYSIZE_UNSAFE(kPreloadedSNISTS);
543 551
544 `) 552 `)
545 553
546 return nil 554 return nil
547 } 555 }
OLDNEW
« net/base/transport_security_state_static.h ('K') | « net/base/transport_security_state_static.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698