Skip to content

Commit

Permalink
Set time directly on the x509 store
Browse files Browse the repository at this point in the history
Instead of an ivar, so other ossl functions that take a store will use the correct time when verifying
  • Loading branch information
segiddins committed Jun 25, 2024
1 parent c737234 commit a508d5c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ext/openssl/ossl_x509store.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
rb_iv_set(self, "@error", Qnil);
rb_iv_set(self, "@error_string", Qnil);
rb_iv_set(self, "@chain", Qnil);
rb_iv_set(self, "@time", Qnil);

return self;
}
Expand Down Expand Up @@ -329,7 +328,12 @@ ossl_x509store_set_trust(VALUE self, VALUE trust)
static VALUE
ossl_x509store_set_time(VALUE self, VALUE time)
{
rb_iv_set(self, "@time", time);
X509_STORE *store;
X509_VERIFY_PARAM *param;

GetX509Store(self, store);
param = X509_STORE_get0_param(store);
X509_VERIFY_PARAM_set_time(param, NUM2LONG(rb_Integer(time)));
return time;
}

Expand Down Expand Up @@ -575,7 +579,7 @@ static VALUE ossl_x509stctx_set_time(VALUE, VALUE);
static VALUE
ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE store, cert, chain, t;
VALUE store, cert, chain;
X509_STORE_CTX *ctx;
X509_STORE *x509st;
X509 *x509 = NULL;
Expand All @@ -599,8 +603,6 @@ ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
sk_X509_pop_free(x509s, X509_free);
ossl_raise(eX509StoreError, "X509_STORE_CTX_init");
}
if (!NIL_P(t = rb_iv_get(store, "@time")))
ossl_x509stctx_set_time(self, t);
rb_iv_set(self, "@verify_callback", rb_iv_get(store, "@verify_callback"));
rb_iv_set(self, "@cert", cert);

Expand Down

0 comments on commit a508d5c

Please sign in to comment.