OLD | NEW |
---|---|
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 #include "net/base/x509_certificate.h" | 5 #include "net/base/x509_certificate.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <cryptohi.h> | 8 #include <cryptohi.h> |
9 #include <keyhi.h> | 9 #include <keyhi.h> |
10 #include <nss.h> | 10 #include <nss.h> |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 std::vector<CERTCertificate*> verified_chain; | 187 std::vector<CERTCertificate*> verified_chain; |
188 int i = 0; | 188 int i = 0; |
189 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list); | 189 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list); |
190 !CERT_LIST_END(node, cert_list); | 190 !CERT_LIST_END(node, cert_list); |
191 node = CERT_LIST_NEXT(node), ++i) { | 191 node = CERT_LIST_NEXT(node), ++i) { |
192 if (i == 0) { | 192 if (i == 0) { |
193 verified_cert = node->cert; | 193 verified_cert = node->cert; |
194 } else { | 194 } else { |
195 verified_chain.push_back(node->cert); | 195 verified_chain.push_back(node->cert); |
196 } | 196 } |
197 | |
198 // Because of an NSS bug, CERT_PKIXVerifyCert may chain one self-signed | |
199 // certificate of a root CA to another self-signed certificate of the | |
200 // same root CA. Detect that error and ignore the root CA certificate. | |
201 // See https://bugzilla.mozilla.org/show_bug.cgi?id=721288. | |
202 if (node->cert->isRoot && root_cert && | |
wtc
2012/01/26 03:10:23
The isRoot member of the NSS CERTCertificate struc
Ryan Sleevi
2012/01/26 04:36:27
I think I'd be interested in seeing a unit test. I
wtc
2012/01/27 02:54:04
I will add a unit test tomorrow.
| |
203 SECITEM_ItemsAreEqual(&node->cert->derSubject, | |
204 &root_cert->derSubject)) { | |
205 continue; | |
206 } | |
207 | |
197 SECAlgorithmID& signature = node->cert->signature; | 208 SECAlgorithmID& signature = node->cert->signature; |
198 SECOidTag oid_tag = SECOID_FindOIDTag(&signature.algorithm); | 209 SECOidTag oid_tag = SECOID_FindOIDTag(&signature.algorithm); |
199 switch (oid_tag) { | 210 switch (oid_tag) { |
200 case SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION: | 211 case SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION: |
201 verify_result->has_md5 = true; | 212 verify_result->has_md5 = true; |
202 if (i != 0) | 213 if (i != 0) |
203 verify_result->has_md5_ca = true; | 214 verify_result->has_md5_ca = true; |
204 break; | 215 break; |
205 case SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION: | 216 case SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION: |
206 verify_result->has_md2 = true; | 217 verify_result->has_md2 = true; |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 *type = kPublicKeyTypeECDSA; | 1180 *type = kPublicKeyTypeECDSA; |
1170 break; | 1181 break; |
1171 default: | 1182 default: |
1172 *type = kPublicKeyTypeUnknown; | 1183 *type = kPublicKeyTypeUnknown; |
1173 *size_bits = 0; | 1184 *size_bits = 0; |
1174 break; | 1185 break; |
1175 } | 1186 } |
1176 } | 1187 } |
1177 | 1188 |
1178 } // namespace net | 1189 } // namespace net |
OLD | NEW |