Default CT_POLICY_EVAL_CTX.epoch_time_in_ms to time()
authorRob Percival <robpercival@google.com>
Mon, 12 Sep 2016 15:57:38 +0000 (16:57 +0100)
committerRich Salz <rsalz@openssl.org>
Tue, 15 Nov 2016 21:12:41 +0000 (16:12 -0500)
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1554)

crypto/ct/ct_policy.c
doc/man3/CT_POLICY_EVAL_CTX_new.pod

index 074589db938442cbca0342537bb0bb7f0ff1ca84..d2f72c4a5a0b0182e7c028c81cd7fb7fd17bd190 100644 (file)
 
 #include <openssl/ct.h>
 #include <openssl/err.h>
+#include <time.h>
 
 #include "ct_locl.h"
 
 CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void)
 {
     CT_POLICY_EVAL_CTX *ctx = OPENSSL_zalloc(sizeof(CT_POLICY_EVAL_CTX));
+    time_t epoch_time_in_s;
 
     if (ctx == NULL) {
         CTerr(CT_F_CT_POLICY_EVAL_CTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
 
+    // Use the current time if available.
+    time(&epoch_time_in_s);
+    if (epoch_time_in_s != -1)
+        ctx->epoch_time_in_ms = epoch_time_in_s * 1000;
+
     return ctx;
 }
 
index fe25cd9cae4d86e1a3f046aafb40fe287fc90564..e0fb7c1ebcbf16f38724ed57cecd30488ab2fae0 100644 (file)
@@ -68,8 +68,8 @@ CT_POLICY_EVAL_CTX.
 
 The SCT timestamp will be compared to this time to check whether the SCT was
 issued in the future. RFC6962 states that "TLS clients MUST reject SCTs whose
-timestamp is in the future". Typically, the time provided to this function will
-be the current time.
+timestamp is in the future". By default, this will be set to the
+current time (obtained by calling time()) if possible.
 
 The time should be in milliseconds since the Unix epoch.