LEFT | RIGHT |
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 "encoding/pem" | 8 "encoding/pem" |
9 ) | 9 ) |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 make(map[string][]int), | 21 make(map[string][]int), |
22 make(map[string][]int), | 22 make(map[string][]int), |
23 nil, | 23 nil, |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 // findVerifiedParents attempts to find certificates in s which have signed the | 27 // findVerifiedParents attempts to find certificates in s which have signed the |
28 // given certificate. If no such certificate can be found or the signature | 28 // given certificate. If no such certificate can be found or the signature |
29 // doesn't match, it returns nil. | 29 // doesn't match, it returns nil. |
30 func (s *CertPool) findVerifiedParents(cert *Certificate) (parents []int) { | 30 func (s *CertPool) findVerifiedParents(cert *Certificate) (parents []int) { |
| 31 if s == nil { |
| 32 return |
| 33 } |
31 var candidates []int | 34 var candidates []int |
32 | 35 |
33 if len(cert.AuthorityKeyId) > 0 { | 36 if len(cert.AuthorityKeyId) > 0 { |
34 candidates = s.bySubjectKeyId[string(cert.AuthorityKeyId)] | 37 candidates = s.bySubjectKeyId[string(cert.AuthorityKeyId)] |
35 } | 38 } |
36 if len(candidates) == 0 { | 39 if len(candidates) == 0 { |
37 candidates = s.byName[string(cert.RawIssuer)] | 40 candidates = s.byName[string(cert.RawIssuer)] |
38 } | 41 } |
39 | 42 |
40 for _, c := range candidates { | 43 for _, c := range candidates { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 104 |
102 // Subjects returns a list of the DER-encoded subjects of | 105 // Subjects returns a list of the DER-encoded subjects of |
103 // all of the certificates in the pool.· | 106 // all of the certificates in the pool.· |
104 func (s *CertPool) Subjects() (res [][]byte) { | 107 func (s *CertPool) Subjects() (res [][]byte) { |
105 res = make([][]byte, len(s.certs)) | 108 res = make([][]byte, len(s.certs)) |
106 for i, c := range s.certs { | 109 for i, c := range s.certs { |
107 res[i] = c.RawSubject | 110 res[i] = c.RawSubject |
108 } | 111 } |
109 return | 112 return |
110 } | 113 } |
LEFT | RIGHT |