End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
OpenSSL::X509::Extension.new
OpenSSL::X509::Extension.new(der)
OpenSSL::X509::Extension.new(oid, value)
OpenSSL::X509::Extension.new(oid, value, critical)
ext/openssl/ossl_x509ext.c
View on GitHub ↗
static VALUE
ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE oid, value, critical;
const unsigned char *p;
X509_EXTENSION *ext, *x;
GetX509Ext(self, ext);
if(rb_scan_args(argc, argv, "12", &oid, &value, &critical) == 1){
oid = ossl_to_der_if_possible(oid);
StringValue(oid);
p = (unsigned char *)RSTRING_PTR(oid);
x = d2i_X509_EXTENSION(&ext, &p, RSTRING_LEN(oid));
DATA_PTR(self) = ext;
if(!x)
ossl_raise(eX509ExtError, NULL);
return self;
}
rb_funcall(self, rb_intern("oid="), 1, oid);
rb_funcall(self, rb_intern("value="), 1, value);
if(argc > 2) rb_funcall(self, rb_intern("critical="), 1, critical);
return self;
}
Creates an X509 extension.
The extension may be created from der data or from an extension oid and value. The oid may be either an OID or an extension name. If critical is true the extension is marked critical.