Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: net/base/x509_util_nss.cc

Issue 8890073: Handle Origin Bound Certificate expiration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review changes Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/x509_util_nss.h ('k') | net/base/x509_util_nss_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/x509_util_nss.cc
diff --git a/net/base/x509_util_nss.cc b/net/base/x509_util_nss.cc
index 61126af6a1fbc68f65e5f664fc17103a33505b94..3f630e259c5b65591a6ff257735e2ac4c5ee193e 100644
--- a/net/base/x509_util_nss.cc
+++ b/net/base/x509_util_nss.cc
@@ -78,7 +78,8 @@ CERTCertificate* CreateCertificate(
SECKEYPublicKey* public_key,
const std::string& subject,
uint32 serial_number,
- base::TimeDelta valid_duration) {
+ base::Time not_valid_before,
+ base::Time not_valid_after) {
// Create info about public key.
CERTSubjectPublicKeyInfo* spki =
SECKEY_CreateSubjectPublicKeyInfo(public_key);
@@ -99,11 +100,9 @@ CERTCertificate* CreateCertificate(
return NULL;
}
- PRTime now = PR_Now();
- PRTime not_after = now + valid_duration.InMicroseconds();
-
- // Note that the time is now in micro-second unit.
- CERTValidity* validity = CERT_CreateValidity(now, not_after);
+ CERTValidity* validity = CERT_CreateValidity(
+ crypto::BaseTimeToPRTime(not_valid_before),
+ crypto::BaseTimeToPRTime(not_valid_after));
CERTCertificate* cert = CERT_CreateCertificate(serial_number, subject_name,
validity, cert_request);
if (!cert) {
@@ -176,13 +175,15 @@ bool CreateOriginBoundCertInternal(
SECKEYPrivateKey* private_key,
const std::string& origin,
uint32 serial_number,
- base::TimeDelta valid_duration,
+ base::Time not_valid_before,
+ base::Time not_valid_after,
std::string* der_cert) {
CERTCertificate* cert = CreateCertificate(public_key,
"CN=anonymous.invalid",
serial_number,
- valid_duration);
+ not_valid_before,
+ not_valid_after);
if (!cert)
return false;
@@ -254,11 +255,13 @@ CERTCertificate* CreateSelfSignedCert(
SECKEYPrivateKey* private_key,
const std::string& subject,
uint32 serial_number,
- base::TimeDelta valid_duration) {
+ base::Time not_valid_before,
+ base::Time not_valid_after) {
CERTCertificate* cert = CreateCertificate(public_key,
subject,
serial_number,
- valid_duration);
+ not_valid_before,
+ not_valid_after);
if (!cert)
return NULL;
@@ -274,7 +277,8 @@ bool CreateOriginBoundCertRSA(
crypto::RSAPrivateKey* key,
const std::string& origin,
uint32 serial_number,
- base::TimeDelta valid_duration,
+ base::Time not_valid_before,
+ base::Time not_valid_after,
std::string* der_cert) {
DCHECK(key);
@@ -329,7 +333,8 @@ bool CreateOriginBoundCertRSA(
private_key,
origin,
serial_number,
- valid_duration,
+ not_valid_before,
+ not_valid_after,
der_cert);
}
@@ -337,14 +342,16 @@ bool CreateOriginBoundCertEC(
crypto::ECPrivateKey* key,
const std::string& origin,
uint32 serial_number,
- base::TimeDelta valid_duration,
+ base::Time not_valid_before,
+ base::Time not_valid_after,
std::string* der_cert) {
DCHECK(key);
return CreateOriginBoundCertInternal(key->public_key(),
key->key(),
origin,
serial_number,
- valid_duration,
+ not_valid_before,
+ not_valid_after,
der_cert);
}
« no previous file with comments | « net/base/x509_util_nss.h ('k') | net/base/x509_util_nss_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698