Skip to content

Commit e4b656e

Browse files
POC for certificates/CRLs
1 parent b1c44db commit e4b656e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

ext/openssl/ossl_x509store.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
224224
rb_iv_set(self, "@error_string", Qnil);
225225
rb_iv_set(self, "@chain", Qnil);
226226

227+
/* added certificate/CRL references */
228+
rb_iv_set(self, "@certificates", rb_ary_new());
229+
rb_iv_set(self, "@crls", rb_ary_new());
230+
227231
return self;
228232
}
229233

@@ -449,8 +453,16 @@ ossl_x509store_add_cert(VALUE self, VALUE arg)
449453
{
450454
X509_STORE *store;
451455
X509 *cert;
456+
VALUE certificates;
452457

453458
rb_check_frozen(self);
459+
460+
certificates = rb_iv_get(self, "@certificates");
461+
462+
463+
if(RTEST(rb_funcall(certificates, rb_intern("include?"), 1, arg)))
464+
return self;
465+
454466
cert = GetX509CertPtr(arg); /* NO NEED TO DUP */
455467
GetX509Store(self, store);
456468
if (X509_STORE_add_cert(store, cert) != 1)
@@ -472,8 +484,15 @@ ossl_x509store_add_crl(VALUE self, VALUE arg)
472484
{
473485
X509_STORE *store;
474486
X509_CRL *crl;
487+
VALUE crls;
475488

476489
rb_check_frozen(self);
490+
491+
crls = rb_iv_get(self, "@crls");
492+
493+
if(RTEST(rb_funcall(crls, rb_intern("include?"), 1, arg)))
494+
return self;
495+
477496
crl = GetX509CRLPtr(arg); /* NO NEED TO DUP */
478497
GetX509Store(self, store);
479498
if (X509_STORE_add_crl(store, crl) != 1)

lib/openssl/x509.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@ def ==(other)
333333
end
334334
end
335335

336+
class Store
337+
def freeze
338+
super
339+
@certificates.each(&:freeze)
340+
@crls.each(&:freeze)
341+
end
342+
end
343+
336344
class StoreContext
337345
def cleanup
338346
warn "(#{caller.first}) OpenSSL::X509::StoreContext#cleanup is deprecated with no replacement" if $VERBOSE

0 commit comments

Comments
 (0)