| 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 <keyhi.h> | 9 #include <keyhi.h> |
| 10 #include <nss.h> | 10 #include <nss.h> |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 } | 771 } |
| 772 | 772 |
| 773 // static | 773 // static |
| 774 X509Certificate* X509Certificate::CreateSelfSigned( | 774 X509Certificate* X509Certificate::CreateSelfSigned( |
| 775 crypto::RSAPrivateKey* key, | 775 crypto::RSAPrivateKey* key, |
| 776 const std::string& subject, | 776 const std::string& subject, |
| 777 uint32 serial_number, | 777 uint32 serial_number, |
| 778 base::TimeDelta valid_duration) { | 778 base::TimeDelta valid_duration) { |
| 779 DCHECK(key); | 779 DCHECK(key); |
| 780 | 780 |
| 781 base::Time not_valid_before = base::Time::Now(); |
| 782 base::Time not_valid_after = not_valid_before + valid_duration; |
| 781 CERTCertificate* cert = x509_util::CreateSelfSignedCert(key->public_key(), | 783 CERTCertificate* cert = x509_util::CreateSelfSignedCert(key->public_key(), |
| 782 key->key(), | 784 key->key(), |
| 783 subject, | 785 subject, |
| 784 serial_number, | 786 serial_number, |
| 785 valid_duration); | 787 not_valid_before, |
| 788 not_valid_after); |
| 786 | 789 |
| 787 if (!cert) | 790 if (!cert) |
| 788 return NULL; | 791 return NULL; |
| 789 | 792 |
| 790 X509Certificate* x509_cert = X509Certificate::CreateFromHandle( | 793 X509Certificate* x509_cert = X509Certificate::CreateFromHandle( |
| 791 cert, X509Certificate::OSCertHandles()); | 794 cert, X509Certificate::OSCertHandles()); |
| 792 CERT_DestroyCertificate(cert); | 795 CERT_DestroyCertificate(cert); |
| 793 return x509_cert; | 796 return x509_cert; |
| 794 } | 797 } |
| 795 | 798 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 *type = kPublicKeyTypeECDSA; | 1174 *type = kPublicKeyTypeECDSA; |
| 1172 break; | 1175 break; |
| 1173 default: | 1176 default: |
| 1174 *type = kPublicKeyTypeUnknown; | 1177 *type = kPublicKeyTypeUnknown; |
| 1175 *size_bits = 0; | 1178 *size_bits = 0; |
| 1176 break; | 1179 break; |
| 1177 } | 1180 } |
| 1178 } | 1181 } |
| 1179 | 1182 |
| 1180 } // namespace net | 1183 } // namespace net |
| OLD | NEW |