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/cert/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
6 | 6 |
7 #include <CommonCrypto/CommonDigest.h> | 7 #include <CommonCrypto/CommonDigest.h> |
8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
9 #include <Security/Security.h> | 9 #include <Security/Security.h> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 distinguished_name.field()->Length); | 43 distinguished_name.field()->Length); |
44 } | 44 } |
45 | 45 |
46 bool IsCertIssuerInEncodedList(X509Certificate::OSCertHandle cert_handle, | 46 bool IsCertIssuerInEncodedList(X509Certificate::OSCertHandle cert_handle, |
47 const std::vector<std::string>& issuers) { | 47 const std::vector<std::string>& issuers) { |
48 x509_util::CSSMCachedCertificate cached_cert; | 48 x509_util::CSSMCachedCertificate cached_cert; |
49 if (cached_cert.Init(cert_handle) != CSSM_OK) | 49 if (cached_cert.Init(cert_handle) != CSSM_OK) |
50 return false; | 50 return false; |
51 | 51 |
52 x509_util::CSSMFieldValue distinguished_name; | 52 x509_util::CSSMFieldValue distinguished_name; |
53 OSStatus status = cached_cert.GetField(&CSSMOID_X509V1IssuerNameStd, | 53 OSStatus status = |
54 &distinguished_name); | 54 cached_cert.GetField(&CSSMOID_X509V1IssuerNameStd, &distinguished_name); |
55 if (status || !distinguished_name.field()) | 55 if (status || !distinguished_name.field()) |
56 return false; | 56 return false; |
57 | 57 |
58 base::StringPiece name_piece( | 58 base::StringPiece name_piece( |
59 reinterpret_cast<const char*>(distinguished_name.field()->Data), | 59 reinterpret_cast<const char*>(distinguished_name.field()->Data), |
60 static_cast<size_t>(distinguished_name.field()->Length)); | 60 static_cast<size_t>(distinguished_name.field()->Length)); |
61 | 61 |
62 for (std::vector<std::string>::const_iterator it = issuers.begin(); | 62 for (std::vector<std::string>::const_iterator it = issuers.begin(); |
63 it != issuers.end(); ++it) { | 63 it != issuers.end(); |
| 64 ++it) { |
64 base::StringPiece issuer_piece(*it); | 65 base::StringPiece issuer_piece(*it); |
65 if (name_piece == issuer_piece) | 66 if (name_piece == issuer_piece) |
66 return true; | 67 return true; |
67 } | 68 } |
68 | 69 |
69 return false; | 70 return false; |
70 } | 71 } |
71 | 72 |
72 void GetCertDateForOID(const x509_util::CSSMCachedCertificate& cached_cert, | 73 void GetCertDateForOID(const x509_util::CSSMCachedCertificate& cached_cert, |
73 const CSSM_OID* oid, | 74 const CSSM_OID* oid, |
74 Time* result) { | 75 Time* result) { |
75 *result = Time::Time(); | 76 *result = Time::Time(); |
76 | 77 |
77 x509_util::CSSMFieldValue field; | 78 x509_util::CSSMFieldValue field; |
78 OSStatus status = cached_cert.GetField(oid, &field); | 79 OSStatus status = cached_cert.GetField(oid, &field); |
79 if (status) | 80 if (status) |
80 return; | 81 return; |
81 | 82 |
82 const CSSM_X509_TIME* x509_time = field.GetAs<CSSM_X509_TIME>(); | 83 const CSSM_X509_TIME* x509_time = field.GetAs<CSSM_X509_TIME>(); |
83 if (x509_time->timeType != BER_TAG_UTC_TIME && | 84 if (x509_time->timeType != BER_TAG_UTC_TIME && |
84 x509_time->timeType != BER_TAG_GENERALIZED_TIME) { | 85 x509_time->timeType != BER_TAG_GENERALIZED_TIME) { |
85 LOG(ERROR) << "Unsupported date/time format " | 86 LOG(ERROR) << "Unsupported date/time format " << x509_time->timeType; |
86 << x509_time->timeType; | |
87 return; | 87 return; |
88 } | 88 } |
89 | 89 |
90 base::StringPiece time_string( | 90 base::StringPiece time_string( |
91 reinterpret_cast<const char*>(x509_time->time.Data), | 91 reinterpret_cast<const char*>(x509_time->time.Data), |
92 x509_time->time.Length); | 92 x509_time->time.Length); |
93 CertDateFormat format = x509_time->timeType == BER_TAG_UTC_TIME ? | 93 CertDateFormat format = x509_time->timeType == BER_TAG_UTC_TIME |
94 CERT_DATE_FORMAT_UTC_TIME : CERT_DATE_FORMAT_GENERALIZED_TIME; | 94 ? CERT_DATE_FORMAT_UTC_TIME |
| 95 : CERT_DATE_FORMAT_GENERALIZED_TIME; |
95 if (!ParseCertificateDate(time_string, format, result)) | 96 if (!ParseCertificateDate(time_string, format, result)) |
96 LOG(ERROR) << "Invalid certificate date/time " << time_string; | 97 LOG(ERROR) << "Invalid certificate date/time " << time_string; |
97 } | 98 } |
98 | 99 |
99 std::string GetCertSerialNumber( | 100 std::string GetCertSerialNumber( |
100 const x509_util::CSSMCachedCertificate& cached_cert) { | 101 const x509_util::CSSMCachedCertificate& cached_cert) { |
101 x509_util::CSSMFieldValue serial_number; | 102 x509_util::CSSMFieldValue serial_number; |
102 OSStatus status = cached_cert.GetField(&CSSMOID_X509V1SerialNumber, | 103 OSStatus status = |
103 &serial_number); | 104 cached_cert.GetField(&CSSMOID_X509V1SerialNumber, &serial_number); |
104 if (status || !serial_number.field()) | 105 if (status || !serial_number.field()) |
105 return std::string(); | 106 return std::string(); |
106 | 107 |
107 return std::string( | 108 return std::string(reinterpret_cast<const char*>(serial_number.field()->Data), |
108 reinterpret_cast<const char*>(serial_number.field()->Data), | 109 serial_number.field()->Length); |
109 serial_number.field()->Length); | |
110 } | 110 } |
111 | 111 |
112 // Returns true if |purpose| is listed as allowed in |usage|. This | 112 // Returns true if |purpose| is listed as allowed in |usage|. This |
113 // function also considers the "Any" purpose. If the attribute is | 113 // function also considers the "Any" purpose. If the attribute is |
114 // present and empty, we return false. | 114 // present and empty, we return false. |
115 bool ExtendedKeyUsageAllows(const CE_ExtendedKeyUsage* usage, | 115 bool ExtendedKeyUsageAllows(const CE_ExtendedKeyUsage* usage, |
116 const CSSM_OID* purpose) { | 116 const CSSM_OID* purpose) { |
117 for (unsigned p = 0; p < usage->numPurposes; ++p) { | 117 for (unsigned p = 0; p < usage->numPurposes; ++p) { |
118 if (CSSMOIDEqual(&usage->purposes[p], purpose)) | 118 if (CSSMOIDEqual(&usage->purposes[p], purpose)) |
119 return true; | 119 return true; |
(...skipping 16 matching lines...) Expand all Loading... |
136 // parsed as a valid X.509 certificate. | 136 // parsed as a valid X.509 certificate. |
137 bool IsValidOSCertHandle(SecCertificateRef cert_handle) { | 137 bool IsValidOSCertHandle(SecCertificateRef cert_handle) { |
138 const CSSM_X509_NAME* sanity_check = NULL; | 138 const CSSM_X509_NAME* sanity_check = NULL; |
139 OSStatus status = SecCertificateGetSubject(cert_handle, &sanity_check); | 139 OSStatus status = SecCertificateGetSubject(cert_handle, &sanity_check); |
140 return status == noErr && sanity_check; | 140 return status == noErr && sanity_check; |
141 } | 141 } |
142 | 142 |
143 // Parses |data| of length |length|, attempting to decode it as the specified | 143 // Parses |data| of length |length|, attempting to decode it as the specified |
144 // |format|. If |data| is in the specified format, any certificates contained | 144 // |format|. If |data| is in the specified format, any certificates contained |
145 // within are stored into |output|. | 145 // within are stored into |output|. |
146 void AddCertificatesFromBytes(const char* data, size_t length, | 146 void AddCertificatesFromBytes(const char* data, |
| 147 size_t length, |
147 SecExternalFormat format, | 148 SecExternalFormat format, |
148 X509Certificate::OSCertHandles* output) { | 149 X509Certificate::OSCertHandles* output) { |
149 SecExternalFormat input_format = format; | 150 SecExternalFormat input_format = format; |
150 ScopedCFTypeRef<CFDataRef> local_data(CFDataCreateWithBytesNoCopy( | 151 ScopedCFTypeRef<CFDataRef> local_data( |
151 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(data), length, | 152 CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, |
152 kCFAllocatorNull)); | 153 reinterpret_cast<const UInt8*>(data), |
| 154 length, |
| 155 kCFAllocatorNull)); |
153 | 156 |
154 CFArrayRef items = NULL; | 157 CFArrayRef items = NULL; |
155 OSStatus status; | 158 OSStatus status; |
156 { | 159 { |
157 base::AutoLock lock(crypto::GetMacSecurityServicesLock()); | 160 base::AutoLock lock(crypto::GetMacSecurityServicesLock()); |
158 status = SecKeychainItemImport(local_data, NULL, &input_format, | 161 status = SecKeychainItemImport( |
159 NULL, 0, NULL, NULL, &items); | 162 local_data, NULL, &input_format, NULL, 0, NULL, NULL, &items); |
160 } | 163 } |
161 | 164 |
162 if (status) { | 165 if (status) { |
163 OSSTATUS_DLOG(WARNING, status) | 166 OSSTATUS_DLOG(WARNING, status) |
164 << "Unable to import items from data of length " << length; | 167 << "Unable to import items from data of length " << length; |
165 return; | 168 return; |
166 } | 169 } |
167 | 170 |
168 ScopedCFTypeRef<CFArrayRef> scoped_items(items); | 171 ScopedCFTypeRef<CFArrayRef> scoped_items(items); |
169 CFTypeID cert_type_id = SecCertificateGetTypeID(); | 172 CFTypeID cert_type_id = SecCertificateGetTypeID(); |
(...skipping 24 matching lines...) Expand all Loading... |
194 } | 197 } |
195 } | 198 } |
196 } | 199 } |
197 } | 200 } |
198 | 201 |
199 } // namespace | 202 } // namespace |
200 | 203 |
201 void X509Certificate::Initialize() { | 204 void X509Certificate::Initialize() { |
202 x509_util::CSSMCachedCertificate cached_cert; | 205 x509_util::CSSMCachedCertificate cached_cert; |
203 if (cached_cert.Init(cert_handle_) == CSSM_OK) { | 206 if (cached_cert.Init(cert_handle_) == CSSM_OK) { |
204 GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1SubjectNameStd, | 207 GetCertDistinguishedName( |
205 &subject_); | 208 cached_cert, &CSSMOID_X509V1SubjectNameStd, &subject_); |
206 GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1IssuerNameStd, | 209 GetCertDistinguishedName( |
207 &issuer_); | 210 cached_cert, &CSSMOID_X509V1IssuerNameStd, &issuer_); |
208 GetCertDateForOID(cached_cert, &CSSMOID_X509V1ValidityNotBefore, | 211 GetCertDateForOID( |
209 &valid_start_); | 212 cached_cert, &CSSMOID_X509V1ValidityNotBefore, &valid_start_); |
210 GetCertDateForOID(cached_cert, &CSSMOID_X509V1ValidityNotAfter, | 213 GetCertDateForOID( |
211 &valid_expiry_); | 214 cached_cert, &CSSMOID_X509V1ValidityNotAfter, &valid_expiry_); |
212 serial_number_ = GetCertSerialNumber(cached_cert); | 215 serial_number_ = GetCertSerialNumber(cached_cert); |
213 } | 216 } |
214 | 217 |
215 fingerprint_ = CalculateFingerprint(cert_handle_); | 218 fingerprint_ = CalculateFingerprint(cert_handle_); |
216 ca_fingerprint_ = CalculateCAFingerprint(intermediate_ca_certs_); | 219 ca_fingerprint_ = CalculateCAFingerprint(intermediate_ca_certs_); |
217 } | 220 } |
218 | 221 |
219 bool X509Certificate::IsIssuedByEncoded( | 222 bool X509Certificate::IsIssuedByEncoded( |
220 const std::vector<std::string>& valid_issuers) { | 223 const std::vector<std::string>& valid_issuers) { |
221 if (IsCertIssuerInEncodedList(cert_handle_, valid_issuers)) | 224 if (IsCertIssuerInEncodedList(cert_handle_, valid_issuers)) |
222 return true; | 225 return true; |
223 | 226 |
224 for (OSCertHandles::iterator it = intermediate_ca_certs_.begin(); | 227 for (OSCertHandles::iterator it = intermediate_ca_certs_.begin(); |
225 it != intermediate_ca_certs_.end(); ++it) { | 228 it != intermediate_ca_certs_.end(); |
| 229 ++it) { |
226 if (IsCertIssuerInEncodedList(*it, valid_issuers)) | 230 if (IsCertIssuerInEncodedList(*it, valid_issuers)) |
227 return true; | 231 return true; |
228 } | 232 } |
229 return false; | 233 return false; |
230 } | 234 } |
231 | 235 |
232 void X509Certificate::GetSubjectAltName( | 236 void X509Certificate::GetSubjectAltName( |
233 std::vector<std::string>* dns_names, | 237 std::vector<std::string>* dns_names, |
234 std::vector<std::string>* ip_addrs) const { | 238 std::vector<std::string>* ip_addrs) const { |
235 if (dns_names) | 239 if (dns_names) |
(...skipping 17 matching lines...) Expand all Loading... |
253 reinterpret_cast<const CE_GeneralNames*>(cssm_ext->value.parsedValue); | 257 reinterpret_cast<const CE_GeneralNames*>(cssm_ext->value.parsedValue); |
254 | 258 |
255 for (size_t name = 0; name < alt_name->numNames; ++name) { | 259 for (size_t name = 0; name < alt_name->numNames; ++name) { |
256 const CE_GeneralName& name_struct = alt_name->generalName[name]; | 260 const CE_GeneralName& name_struct = alt_name->generalName[name]; |
257 const CSSM_DATA& name_data = name_struct.name; | 261 const CSSM_DATA& name_data = name_struct.name; |
258 // DNSName and IPAddress are encoded as IA5String and OCTET STRINGs | 262 // DNSName and IPAddress are encoded as IA5String and OCTET STRINGs |
259 // respectively, both of which can be byte copied from | 263 // respectively, both of which can be byte copied from |
260 // CSSM_DATA::data into the appropriate output vector. | 264 // CSSM_DATA::data into the appropriate output vector. |
261 if (dns_names && name_struct.nameType == GNT_DNSName) { | 265 if (dns_names && name_struct.nameType == GNT_DNSName) { |
262 dns_names->push_back(std::string( | 266 dns_names->push_back(std::string( |
263 reinterpret_cast<const char*>(name_data.Data), | 267 reinterpret_cast<const char*>(name_data.Data), name_data.Length)); |
264 name_data.Length)); | |
265 } else if (ip_addrs && name_struct.nameType == GNT_IPAddress) { | 268 } else if (ip_addrs && name_struct.nameType == GNT_IPAddress) { |
266 ip_addrs->push_back(std::string( | 269 ip_addrs->push_back(std::string( |
267 reinterpret_cast<const char*>(name_data.Data), | 270 reinterpret_cast<const char*>(name_data.Data), name_data.Length)); |
268 name_data.Length)); | |
269 } | 271 } |
270 } | 272 } |
271 } | 273 } |
272 | 274 |
273 // static | 275 // static |
274 bool X509Certificate::GetDEREncoded(X509Certificate::OSCertHandle cert_handle, | 276 bool X509Certificate::GetDEREncoded(X509Certificate::OSCertHandle cert_handle, |
275 std::string* encoded) { | 277 std::string* encoded) { |
276 CSSM_DATA der_data; | 278 CSSM_DATA der_data; |
277 if (SecCertificateGetData(cert_handle, &der_data) != noErr) | 279 if (SecCertificateGetData(cert_handle, &der_data) != noErr) |
278 return false; | 280 return false; |
279 encoded->assign(reinterpret_cast<char*>(der_data.Data), | 281 encoded->assign(reinterpret_cast<char*>(der_data.Data), der_data.Length); |
280 der_data.Length); | |
281 return true; | 282 return true; |
282 } | 283 } |
283 | 284 |
284 // static | 285 // static |
285 bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a, | 286 bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a, |
286 X509Certificate::OSCertHandle b) { | 287 X509Certificate::OSCertHandle b) { |
287 DCHECK(a && b); | 288 DCHECK(a && b); |
288 if (a == b) | 289 if (a == b) |
289 return true; | 290 return true; |
290 if (CFEqual(a, b)) | 291 if (CFEqual(a, b)) |
291 return true; | 292 return true; |
292 CSSM_DATA a_data, b_data; | 293 CSSM_DATA a_data, b_data; |
293 return SecCertificateGetData(a, &a_data) == noErr && | 294 return SecCertificateGetData(a, &a_data) == noErr && |
294 SecCertificateGetData(b, &b_data) == noErr && | 295 SecCertificateGetData(b, &b_data) == noErr && |
295 a_data.Length == b_data.Length && | 296 a_data.Length == b_data.Length && |
296 memcmp(a_data.Data, b_data.Data, a_data.Length) == 0; | 297 memcmp(a_data.Data, b_data.Data, a_data.Length) == 0; |
297 } | 298 } |
298 | 299 |
299 // static | 300 // static |
300 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( | 301 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( |
301 const char* data, int length) { | 302 const char* data, |
| 303 int length) { |
302 CSSM_DATA cert_data; | 304 CSSM_DATA cert_data; |
303 cert_data.Data = const_cast<uint8*>(reinterpret_cast<const uint8*>(data)); | 305 cert_data.Data = const_cast<uint8*>(reinterpret_cast<const uint8*>(data)); |
304 cert_data.Length = length; | 306 cert_data.Length = length; |
305 | 307 |
306 OSCertHandle cert_handle = NULL; | 308 OSCertHandle cert_handle = NULL; |
307 OSStatus status = SecCertificateCreateFromData(&cert_data, | 309 OSStatus status = SecCertificateCreateFromData( |
308 CSSM_CERT_X_509v3, | 310 &cert_data, CSSM_CERT_X_509v3, CSSM_CERT_ENCODING_DER, &cert_handle); |
309 CSSM_CERT_ENCODING_DER, | |
310 &cert_handle); | |
311 if (status != noErr) | 311 if (status != noErr) |
312 return NULL; | 312 return NULL; |
313 if (!IsValidOSCertHandle(cert_handle)) { | 313 if (!IsValidOSCertHandle(cert_handle)) { |
314 CFRelease(cert_handle); | 314 CFRelease(cert_handle); |
315 return NULL; | 315 return NULL; |
316 } | 316 } |
317 return cert_handle; | 317 return cert_handle; |
318 } | 318 } |
319 | 319 |
320 // static | 320 // static |
321 X509Certificate::OSCertHandles X509Certificate::CreateOSCertHandlesFromBytes( | 321 X509Certificate::OSCertHandles X509Certificate::CreateOSCertHandlesFromBytes( |
322 const char* data, int length, Format format) { | 322 const char* data, |
| 323 int length, |
| 324 Format format) { |
323 OSCertHandles results; | 325 OSCertHandles results; |
324 | 326 |
325 switch (format) { | 327 switch (format) { |
326 case FORMAT_SINGLE_CERTIFICATE: { | 328 case FORMAT_SINGLE_CERTIFICATE: { |
327 OSCertHandle handle = CreateOSCertHandleFromBytes(data, length); | 329 OSCertHandle handle = CreateOSCertHandleFromBytes(data, length); |
328 if (handle) | 330 if (handle) |
329 results.push_back(handle); | 331 results.push_back(handle); |
330 break; | 332 break; |
331 } | 333 } |
332 case FORMAT_PKCS7: | 334 case FORMAT_PKCS7: |
(...skipping 14 matching lines...) Expand all Loading... |
347 return NULL; | 349 return NULL; |
348 return reinterpret_cast<OSCertHandle>(const_cast<void*>(CFRetain(handle))); | 350 return reinterpret_cast<OSCertHandle>(const_cast<void*>(CFRetain(handle))); |
349 } | 351 } |
350 | 352 |
351 // static | 353 // static |
352 void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) { | 354 void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) { |
353 CFRelease(cert_handle); | 355 CFRelease(cert_handle); |
354 } | 356 } |
355 | 357 |
356 // static | 358 // static |
357 SHA1HashValue X509Certificate::CalculateFingerprint( | 359 SHA1HashValue X509Certificate::CalculateFingerprint(OSCertHandle cert) { |
358 OSCertHandle cert) { | |
359 SHA1HashValue sha1; | 360 SHA1HashValue sha1; |
360 memset(sha1.data, 0, sizeof(sha1.data)); | 361 memset(sha1.data, 0, sizeof(sha1.data)); |
361 | 362 |
362 CSSM_DATA cert_data; | 363 CSSM_DATA cert_data; |
363 OSStatus status = SecCertificateGetData(cert, &cert_data); | 364 OSStatus status = SecCertificateGetData(cert, &cert_data); |
364 if (status) | 365 if (status) |
365 return sha1; | 366 return sha1; |
366 | 367 |
367 DCHECK(cert_data.Data); | 368 DCHECK(cert_data.Data); |
368 DCHECK_NE(cert_data.Length, 0U); | 369 DCHECK_NE(cert_data.Length, 0U); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 const CE_ExtendedKeyUsage* ext_key_usage = | 426 const CE_ExtendedKeyUsage* ext_key_usage = |
426 reinterpret_cast<const CE_ExtendedKeyUsage*>(ext->value.parsedValue); | 427 reinterpret_cast<const CE_ExtendedKeyUsage*>(ext->value.parsedValue); |
427 if (!ExtendedKeyUsageAllows(ext_key_usage, &CSSMOID_ClientAuth)) | 428 if (!ExtendedKeyUsageAllows(ext_key_usage, &CSSMOID_ClientAuth)) |
428 return false; | 429 return false; |
429 } | 430 } |
430 return true; | 431 return true; |
431 } | 432 } |
432 | 433 |
433 CFArrayRef X509Certificate::CreateOSCertChainForCert() const { | 434 CFArrayRef X509Certificate::CreateOSCertChainForCert() const { |
434 CFMutableArrayRef cert_list = | 435 CFMutableArrayRef cert_list = |
435 CFArrayCreateMutable(kCFAllocatorDefault, 0, | 436 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); |
436 &kCFTypeArrayCallBacks); | |
437 if (!cert_list) | 437 if (!cert_list) |
438 return NULL; | 438 return NULL; |
439 | 439 |
440 CFArrayAppendValue(cert_list, os_cert_handle()); | 440 CFArrayAppendValue(cert_list, os_cert_handle()); |
441 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) | 441 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) |
442 CFArrayAppendValue(cert_list, intermediate_ca_certs_[i]); | 442 CFArrayAppendValue(cert_list, intermediate_ca_certs_[i]); |
443 | 443 |
444 return cert_list; | 444 return cert_list; |
445 } | 445 } |
446 | 446 |
447 // static | 447 // static |
448 X509Certificate::OSCertHandle | 448 X509Certificate::OSCertHandle X509Certificate::ReadOSCertHandleFromPickle( |
449 X509Certificate::ReadOSCertHandleFromPickle(PickleIterator* pickle_iter) { | 449 PickleIterator* pickle_iter) { |
450 const char* data; | 450 const char* data; |
451 int length; | 451 int length; |
452 if (!pickle_iter->ReadData(&data, &length)) | 452 if (!pickle_iter->ReadData(&data, &length)) |
453 return NULL; | 453 return NULL; |
454 | 454 |
455 return CreateOSCertHandleFromBytes(data, length); | 455 return CreateOSCertHandleFromBytes(data, length); |
456 } | 456 } |
457 | 457 |
458 // static | 458 // static |
459 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 459 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 *type = kPublicKeyTypeDH; | 506 *type = kPublicKeyTypeDH; |
507 break; | 507 break; |
508 default: | 508 default: |
509 *type = kPublicKeyTypeUnknown; | 509 *type = kPublicKeyTypeUnknown; |
510 *size_bits = 0; | 510 *size_bits = 0; |
511 break; | 511 break; |
512 } | 512 } |
513 } | 513 } |
514 | 514 |
515 } // namespace net | 515 } // namespace net |
OLD | NEW |