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 <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 OSCertHandle cert_handle = CreateOSCertHandleFromBytes(data, length); | 299 OSCertHandle cert_handle = CreateOSCertHandleFromBytes(data, length); |
300 if (!cert_handle) | 300 if (!cert_handle) |
301 return NULL; | 301 return NULL; |
302 | 302 |
303 X509Certificate* cert = CreateFromHandle(cert_handle, OSCertHandles()); | 303 X509Certificate* cert = CreateFromHandle(cert_handle, OSCertHandles()); |
304 FreeOSCertHandle(cert_handle); | 304 FreeOSCertHandle(cert_handle); |
305 return cert; | 305 return cert; |
306 } | 306 } |
307 | 307 |
308 // static | 308 // static |
309 X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle, | 309 X509Certificate* X509Certificate::CreateFromPickle(PickleIterator* pickle_iter, |
310 PickleIterator* pickle_iter, | |
311 PickleType type) { | 310 PickleType type) { |
312 if (type == PICKLETYPE_CERTIFICATE_CHAIN_V3) { | 311 if (type == PICKLETYPE_CERTIFICATE_CHAIN_V3) { |
313 int chain_length = 0; | 312 int chain_length = 0; |
314 if (!pickle_iter->ReadLength(&chain_length)) | 313 if (!pickle_iter->ReadLength(&chain_length)) |
315 return NULL; | 314 return NULL; |
316 | 315 |
317 std::vector<base::StringPiece> cert_chain; | 316 std::vector<base::StringPiece> cert_chain; |
318 const char* data = NULL; | 317 const char* data = NULL; |
319 int data_length = 0; | 318 int data_length = 0; |
320 for (int i = 0; i < chain_length; ++i) { | 319 for (int i = 0; i < chain_length; ++i) { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 RemoveFromCache(cert_handle_); | 750 RemoveFromCache(cert_handle_); |
752 FreeOSCertHandle(cert_handle_); | 751 FreeOSCertHandle(cert_handle_); |
753 } | 752 } |
754 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) { | 753 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) { |
755 RemoveFromCache(intermediate_ca_certs_[i]); | 754 RemoveFromCache(intermediate_ca_certs_[i]); |
756 FreeOSCertHandle(intermediate_ca_certs_[i]); | 755 FreeOSCertHandle(intermediate_ca_certs_[i]); |
757 } | 756 } |
758 } | 757 } |
759 | 758 |
760 } // namespace net | 759 } // namespace net |
OLD | NEW |