| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/string_tokenizer.h" | 9 #include "base/string_tokenizer.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 return NULL; | 475 return NULL; |
| 476 | 476 |
| 477 OSCertHandle cert_handle = NULL; | 477 OSCertHandle cert_handle = NULL; |
| 478 if (!CertAddSerializedElementToStore( | 478 if (!CertAddSerializedElementToStore( |
| 479 NULL, // the cert won't be persisted in any cert store | 479 NULL, // the cert won't be persisted in any cert store |
| 480 reinterpret_cast<const BYTE*>(data), length, | 480 reinterpret_cast<const BYTE*>(data), length, |
| 481 CERT_STORE_ADD_USE_EXISTING, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, | 481 CERT_STORE_ADD_USE_EXISTING, 0, CERT_STORE_CERTIFICATE_CONTEXT_FLAG, |
| 482 NULL, reinterpret_cast<const void **>(&cert_handle))) | 482 NULL, reinterpret_cast<const void **>(&cert_handle))) |
| 483 return NULL; | 483 return NULL; |
| 484 | 484 |
| 485 return CreateFromHandle(cert_handle, SOURCE_LONE_CERT_IMPORT, | 485 X509Certificate* cert = CreateFromHandle(cert_handle, |
| 486 OSCertHandles()); | 486 SOURCE_LONE_CERT_IMPORT, |
| 487 OSCertHandles()); |
| 488 FreeOSCertHandle(cert_handle); |
| 489 return cert; |
| 487 } | 490 } |
| 488 | 491 |
| 489 void X509Certificate::Persist(Pickle* pickle) { | 492 void X509Certificate::Persist(Pickle* pickle) { |
| 490 DCHECK(cert_handle_); | 493 DCHECK(cert_handle_); |
| 491 DWORD length; | 494 DWORD length; |
| 492 if (!CertSerializeCertificateStoreElement(cert_handle_, 0, | 495 if (!CertSerializeCertificateStoreElement(cert_handle_, 0, |
| 493 NULL, &length)) { | 496 NULL, &length)) { |
| 494 NOTREACHED(); | 497 NOTREACHED(); |
| 495 return; | 498 return; |
| 496 } | 499 } |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 DWORD sha1_size = sizeof(sha1.data); | 776 DWORD sha1_size = sizeof(sha1.data); |
| 774 rv = CryptHashCertificate(NULL, CALG_SHA1, 0, cert->pbCertEncoded, | 777 rv = CryptHashCertificate(NULL, CALG_SHA1, 0, cert->pbCertEncoded, |
| 775 cert->cbCertEncoded, sha1.data, &sha1_size); | 778 cert->cbCertEncoded, sha1.data, &sha1_size); |
| 776 DCHECK(rv && sha1_size == sizeof(sha1.data)); | 779 DCHECK(rv && sha1_size == sizeof(sha1.data)); |
| 777 if (!rv) | 780 if (!rv) |
| 778 memset(sha1.data, 0, sizeof(sha1.data)); | 781 memset(sha1.data, 0, sizeof(sha1.data)); |
| 779 return sha1; | 782 return sha1; |
| 780 } | 783 } |
| 781 | 784 |
| 782 } // namespace net | 785 } // namespace net |
| OLD | NEW |