| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 return NULL; | 457 return NULL; |
| 458 | 458 |
| 459 CFArrayAppendValue(cert_list, os_cert_handle()); | 459 CFArrayAppendValue(cert_list, os_cert_handle()); |
| 460 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) | 460 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) |
| 461 CFArrayAppendValue(cert_list, intermediate_ca_certs_[i]); | 461 CFArrayAppendValue(cert_list, intermediate_ca_certs_[i]); |
| 462 | 462 |
| 463 return cert_list; | 463 return cert_list; |
| 464 } | 464 } |
| 465 | 465 |
| 466 // static | 466 // static |
| 467 X509Certificate::OSCertHandle | 467 X509Certificate::OSCertHandle X509Certificate::ReadOSCertHandleFromPickle( |
| 468 X509Certificate::ReadOSCertHandleFromPickle(PickleIterator* pickle_iter) { | 468 base::PickleIterator* pickle_iter) { |
| 469 const char* data; | 469 const char* data; |
| 470 int length; | 470 int length; |
| 471 if (!pickle_iter->ReadData(&data, &length)) | 471 if (!pickle_iter->ReadData(&data, &length)) |
| 472 return NULL; | 472 return NULL; |
| 473 | 473 |
| 474 return CreateOSCertHandleFromBytes(data, length); | 474 return CreateOSCertHandleFromBytes(data, length); |
| 475 } | 475 } |
| 476 | 476 |
| 477 // static | 477 // static |
| 478 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 478 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
| 479 Pickle* pickle) { | 479 base::Pickle* pickle) { |
| 480 CSSM_DATA cert_data; | 480 CSSM_DATA cert_data; |
| 481 OSStatus status = SecCertificateGetData(cert_handle, &cert_data); | 481 OSStatus status = SecCertificateGetData(cert_handle, &cert_data); |
| 482 if (status) | 482 if (status) |
| 483 return false; | 483 return false; |
| 484 | 484 |
| 485 return pickle->WriteData(reinterpret_cast<char*>(cert_data.Data), | 485 return pickle->WriteData(reinterpret_cast<char*>(cert_data.Data), |
| 486 cert_data.Length); | 486 cert_data.Length); |
| 487 } | 487 } |
| 488 | 488 |
| 489 // static | 489 // static |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 status = SecCertificateGetData(cert_handle, &cert_data); | 564 status = SecCertificateGetData(cert_handle, &cert_data); |
| 565 if (status) | 565 if (status) |
| 566 return false; | 566 return false; |
| 567 | 567 |
| 568 if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0)) | 568 if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0)) |
| 569 return false; | 569 return false; |
| 570 return true; | 570 return true; |
| 571 } | 571 } |
| 572 | 572 |
| 573 } // namespace net | 573 } // namespace net |
| OLD | NEW |