| 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 <cert.h> | 7 #include <cert.h> |
| 8 #include <cryptohi.h> | 8 #include <cryptohi.h> |
| 9 #include <nss.h> | 9 #include <nss.h> |
| 10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 ParsePrincipal(&cert_handle_->issuer, &issuer_); | 611 ParsePrincipal(&cert_handle_->issuer, &issuer_); |
| 612 | 612 |
| 613 ParseDate(&cert_handle_->validity.notBefore, &valid_start_); | 613 ParseDate(&cert_handle_->validity.notBefore, &valid_start_); |
| 614 ParseDate(&cert_handle_->validity.notAfter, &valid_expiry_); | 614 ParseDate(&cert_handle_->validity.notAfter, &valid_expiry_); |
| 615 | 615 |
| 616 fingerprint_ = CalculateFingerprint(cert_handle_); | 616 fingerprint_ = CalculateFingerprint(cert_handle_); |
| 617 | 617 |
| 618 serial_number_ = std::string( | 618 serial_number_ = std::string( |
| 619 reinterpret_cast<char*>(cert_handle_->serialNumber.data), | 619 reinterpret_cast<char*>(cert_handle_->serialNumber.data), |
| 620 cert_handle_->serialNumber.len); | 620 cert_handle_->serialNumber.len); |
| 621 // Remove leading zeros. | |
| 622 while (serial_number_.size() > 1 && serial_number_[0] == 0) | |
| 623 serial_number_ = serial_number_.substr(1, serial_number_.size() - 1); | |
| 624 } | 621 } |
| 625 | 622 |
| 626 // static | 623 // static |
| 627 X509Certificate* X509Certificate::CreateSelfSigned( | 624 X509Certificate* X509Certificate::CreateSelfSigned( |
| 628 crypto::RSAPrivateKey* key, | 625 crypto::RSAPrivateKey* key, |
| 629 const std::string& subject, | 626 const std::string& subject, |
| 630 uint32 serial_number, | 627 uint32 serial_number, |
| 631 base::TimeDelta valid_duration) { | 628 base::TimeDelta valid_duration) { |
| 632 DCHECK(key); | 629 DCHECK(key); |
| 633 | 630 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 | 925 |
| 929 // static | 926 // static |
| 930 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 927 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
| 931 Pickle* pickle) { | 928 Pickle* pickle) { |
| 932 return pickle->WriteData( | 929 return pickle->WriteData( |
| 933 reinterpret_cast<const char*>(cert_handle->derCert.data), | 930 reinterpret_cast<const char*>(cert_handle->derCert.data), |
| 934 cert_handle->derCert.len); | 931 cert_handle->derCert.len); |
| 935 } | 932 } |
| 936 | 933 |
| 937 } // namespace net | 934 } // namespace net |
| OLD | NEW |