Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(957)

Side by Side Diff: src/pkg/crypto/x509/verify.go

Issue 4657080: code review 4657080: crypto/x509: prevent chain cycles in Verify (Closed)
Patch Set: diff -r 5f2ce0cf2484 https://go.googlecode.com/hg/ Created 13 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/crypto/x509/verify_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 func (c *Certificate) buildChains(cache map[int][][]*Certificate, currentChain [ ]*Certificate, opts *VerifyOptions) (chains [][]*Certificate, err os.Error) { 164 func (c *Certificate) buildChains(cache map[int][][]*Certificate, currentChain [ ]*Certificate, opts *VerifyOptions) (chains [][]*Certificate, err os.Error) {
165 for _, rootNum := range opts.Roots.findVerifiedParents(c) { 165 for _, rootNum := range opts.Roots.findVerifiedParents(c) {
166 root := opts.Roots.certs[rootNum] 166 root := opts.Roots.certs[rootNum]
167 err = root.isValid(rootCertificate, opts) 167 err = root.isValid(rootCertificate, opts)
168 if err != nil { 168 if err != nil {
169 continue 169 continue
170 } 170 }
171 chains = append(chains, appendToFreshChain(currentChain, root)) 171 chains = append(chains, appendToFreshChain(currentChain, root))
172 } 172 }
173 173
174 nextIntermediate:
174 for _, intermediateNum := range opts.Intermediates.findVerifiedParents(c ) { 175 for _, intermediateNum := range opts.Intermediates.findVerifiedParents(c ) {
175 intermediate := opts.Intermediates.certs[intermediateNum] 176 intermediate := opts.Intermediates.certs[intermediateNum]
177 for _, cert := range currentChain {
178 if cert == intermediate {
179 continue nextIntermediate
180 }
181 }
176 err = intermediate.isValid(intermediateCertificate, opts) 182 err = intermediate.isValid(intermediateCertificate, opts)
177 if err != nil { 183 if err != nil {
178 continue 184 continue
179 } 185 }
180 var childChains [][]*Certificate 186 var childChains [][]*Certificate
181 childChains, ok := cache[intermediateNum] 187 childChains, ok := cache[intermediateNum]
182 if !ok { 188 if !ok {
183 childChains, err = intermediate.buildChains(cache, appen dToFreshChain(currentChain, intermediate), opts) 189 childChains, err = intermediate.buildChains(cache, appen dToFreshChain(currentChain, intermediate), opts)
184 cache[intermediateNum] = childChains 190 cache[intermediateNum] = childChains
185 } 191 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return nil 236 return nil
231 } 237 }
232 } 238 }
233 // If Subject Alt Name is given, we ignore the common name. 239 // If Subject Alt Name is given, we ignore the common name.
234 } else if matchHostnames(c.Subject.CommonName, h) { 240 } else if matchHostnames(c.Subject.CommonName, h) {
235 return nil 241 return nil
236 } 242 }
237 243
238 return HostnameError{c, h} 244 return HostnameError{c, h}
239 } 245 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/crypto/x509/verify_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b