OLD | NEW |
---|---|
1 // Copyright (c) 2011 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_cert_types.h" | 5 #include "net/base/x509_cert_types.h" |
6 | 6 |
7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
8 #include <Security/Security.h> | 8 #include <Security/Security.h> |
9 #include <Security/SecAsn1Coder.h> | 9 #include <Security/SecAsn1Coder.h> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/i18n/icu_string_conversions.h" | 12 #include "base/i18n/icu_string_conversions.h" |
13 #include "base/mac/mac_logging.h" | |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 // The BER encoding of 0.9.2342.19200300.100.1.25. | 20 // The BER encoding of 0.9.2342.19200300.100.1.25. |
20 // On 10.6 and later this is available as CSSMOID_DomainComponent, which is an | 21 // On 10.6 and later this is available as CSSMOID_DomainComponent, which is an |
21 // external symbol from Security.framework. However, it appears that Apple's | 22 // external symbol from Security.framework. However, it appears that Apple's |
22 // implementation improperly encoded this on 10.6+, and even still is | 23 // implementation improperly encoded this on 10.6+, and even still is |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 DCHECK(ber_name_data); | 196 DCHECK(ber_name_data); |
196 | 197 |
197 // First parse the BER |name_data| into the above structs. | 198 // First parse the BER |name_data| into the above structs. |
198 SecAsn1CoderRef coder = NULL; | 199 SecAsn1CoderRef coder = NULL; |
199 SecAsn1CoderCreate(&coder); | 200 SecAsn1CoderCreate(&coder); |
200 DCHECK(coder); | 201 DCHECK(coder); |
201 X509Name* name = NULL; | 202 X509Name* name = NULL; |
202 OSStatus err = SecAsn1Decode(coder, ber_name_data, length, kNameTemplate, | 203 OSStatus err = SecAsn1Decode(coder, ber_name_data, length, kNameTemplate, |
203 &name); | 204 &name); |
204 if (err) { | 205 if (err) { |
205 LOG(ERROR) << "SecAsn1Decode returned " << err << "; name=" << name; | 206 OSSTATUS_LOG(ERROR, err) << "SecAsn1Decode name=" << name; |
wtc
2012/01/28 00:06:26
Nit: the message should say SecAsn1Decode failed.
| |
206 SecAsn1CoderRelease(coder); | 207 SecAsn1CoderRelease(coder); |
207 return false; | 208 return false; |
208 } | 209 } |
209 | 210 |
210 // Now scan the structs and add the values to my string vectors. | 211 // Now scan the structs and add the values to my string vectors. |
211 // I don't store multiple common/locality/state/country names, so use | 212 // I don't store multiple common/locality/state/country names, so use |
212 // temporary vectors for those. | 213 // temporary vectors for those. |
213 std::vector<std::string> common_names, locality_names, state_names, | 214 std::vector<std::string> common_names, locality_names, state_names, |
214 country_names; | 215 country_names; |
215 std::vector<std::string>* values[] = { | 216 std::vector<std::string>* values[] = { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 match(locality_name, against.locality_name) && | 281 match(locality_name, against.locality_name) && |
281 match(state_or_province_name, against.state_or_province_name) && | 282 match(state_or_province_name, against.state_or_province_name) && |
282 match(country_name, against.country_name) && | 283 match(country_name, against.country_name) && |
283 match(street_addresses, against.street_addresses) && | 284 match(street_addresses, against.street_addresses) && |
284 match(organization_names, against.organization_names) && | 285 match(organization_names, against.organization_names) && |
285 match(organization_unit_names, against.organization_unit_names) && | 286 match(organization_unit_names, against.organization_unit_names) && |
286 match(domain_components, against.domain_components); | 287 match(domain_components, against.domain_components); |
287 } | 288 } |
288 | 289 |
289 } // namespace net | 290 } // namespace net |
OLD | NEW |