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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 325 |
326 void X509Certificate::Initialize() { | 326 void X509Certificate::Initialize() { |
327 crypto::EnsureOpenSSLInit(); | 327 crypto::EnsureOpenSSLInit(); |
328 fingerprint_ = CalculateFingerprint(cert_handle_); | 328 fingerprint_ = CalculateFingerprint(cert_handle_); |
329 | 329 |
330 ASN1_INTEGER* num = X509_get_serialNumber(cert_handle_); | 330 ASN1_INTEGER* num = X509_get_serialNumber(cert_handle_); |
331 if (num) { | 331 if (num) { |
332 serial_number_ = std::string( | 332 serial_number_ = std::string( |
333 reinterpret_cast<char*>(num->data), | 333 reinterpret_cast<char*>(num->data), |
334 num->length); | 334 num->length); |
335 // Remove leading zeros. | |
336 while (serial_number_.size() > 1 && serial_number_[0] == 0) | |
337 serial_number_ = serial_number_.substr(1, serial_number_.size() - 1); | |
338 } | 335 } |
339 | 336 |
340 ParsePrincipal(cert_handle_, X509_get_subject_name(cert_handle_), &subject_); | 337 ParsePrincipal(cert_handle_, X509_get_subject_name(cert_handle_), &subject_); |
341 ParsePrincipal(cert_handle_, X509_get_issuer_name(cert_handle_), &issuer_); | 338 ParsePrincipal(cert_handle_, X509_get_issuer_name(cert_handle_), &issuer_); |
342 x509_util::ParseDate(X509_get_notBefore(cert_handle_), &valid_start_); | 339 x509_util::ParseDate(X509_get_notBefore(cert_handle_), &valid_start_); |
343 x509_util::ParseDate(X509_get_notAfter(cert_handle_), &valid_expiry_); | 340 x509_util::ParseDate(X509_get_notAfter(cert_handle_), &valid_expiry_); |
344 } | 341 } |
345 | 342 |
346 // static | 343 // static |
347 void X509Certificate::ResetCertStore() { | 344 void X509Certificate::ResetCertStore() { |
(...skipping 205 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 |