| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <openssl/asn1.h> | 7 #include <openssl/asn1.h> |
| 8 #include <openssl/crypto.h> | 8 #include <openssl/crypto.h> |
| 9 #include <openssl/obj_mac.h> | 9 #include <openssl/obj_mac.h> |
| 10 #include <openssl/pem.h> | 10 #include <openssl/pem.h> |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 324 |
| 325 void X509Certificate::Initialize() { | 325 void X509Certificate::Initialize() { |
| 326 crypto::EnsureOpenSSLInit(); | 326 crypto::EnsureOpenSSLInit(); |
| 327 fingerprint_ = CalculateFingerprint(cert_handle_); | 327 fingerprint_ = CalculateFingerprint(cert_handle_); |
| 328 | 328 |
| 329 ASN1_INTEGER* num = X509_get_serialNumber(cert_handle_); | 329 ASN1_INTEGER* num = X509_get_serialNumber(cert_handle_); |
| 330 if (num) { | 330 if (num) { |
| 331 serial_number_ = std::string( | 331 serial_number_ = std::string( |
| 332 reinterpret_cast<char*>(num->data), | 332 reinterpret_cast<char*>(num->data), |
| 333 num->length); | 333 num->length); |
| 334 // Remove leading zeros. | |
| 335 while (serial_number_.size() > 1 && serial_number_[0] == 0) | |
| 336 serial_number_ = serial_number_.substr(1, serial_number_.size() - 1); | |
| 337 } | 334 } |
| 338 | 335 |
| 339 ParsePrincipal(cert_handle_, X509_get_subject_name(cert_handle_), &subject_); | 336 ParsePrincipal(cert_handle_, X509_get_subject_name(cert_handle_), &subject_); |
| 340 ParsePrincipal(cert_handle_, X509_get_issuer_name(cert_handle_), &issuer_); | 337 ParsePrincipal(cert_handle_, X509_get_issuer_name(cert_handle_), &issuer_); |
| 341 x509_util::ParseDate(X509_get_notBefore(cert_handle_), &valid_start_); | 338 x509_util::ParseDate(X509_get_notBefore(cert_handle_), &valid_start_); |
| 342 x509_util::ParseDate(X509_get_notAfter(cert_handle_), &valid_expiry_); | 339 x509_util::ParseDate(X509_get_notAfter(cert_handle_), &valid_expiry_); |
| 343 } | 340 } |
| 344 | 341 |
| 345 // static | 342 // static |
| 346 void X509Certificate::ResetCertStore() { | 343 void X509Certificate::ResetCertStore() { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 DERCache der_cache; | 550 DERCache der_cache; |
| 554 if (!GetDERAndCacheIfNeeded(cert_handle, &der_cache)) | 551 if (!GetDERAndCacheIfNeeded(cert_handle, &der_cache)) |
| 555 return false; | 552 return false; |
| 556 | 553 |
| 557 return pickle->WriteData( | 554 return pickle->WriteData( |
| 558 reinterpret_cast<const char*>(der_cache.data), | 555 reinterpret_cast<const char*>(der_cache.data), |
| 559 der_cache.data_length); | 556 der_cache.data_length); |
| 560 } | 557 } |
| 561 | 558 |
| 562 } // namespace net | 559 } // namespace net |
| OLD | NEW |