Method: OpenSSL::X509::Extension#initialize

Defined in:
ossl_x509ext.c

#OpenSSL::X509::Extension.new(der) ⇒ Object #OpenSSL::X509::Extension.new(oid, value) ⇒ Object #OpenSSL::X509::Extension.new(oid, value, critical) ⇒ Object

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.



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'ossl_x509ext.c', line 272

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;
}