Class: X509::ExtensionFactory

Inherits:
Object
  • Object
show all
Defined in:
ossl_x509ext.c

Instance Method Summary collapse

Constructor Details

#initializeObject

Instance Method Details

#config=Object

#create_extObject

Array to X509_EXTENSION Structure:

"ln", "value", bool_critical

or

"sn", "value", bool_critical

or

"ln", "critical,value"

or the same for sn

"ln", "value"

> not critical



# File 'ossl_x509ext.c'

static VALUE 
ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
{
X509V3_CTX *ctx;
X509_EXTENSION *ext;
VALUE oid, value, critical, valstr, obj;
int nid;
#ifdef HAVE_X509V3_EXT_NCONF_NID
VALUE rconf;
CONF *conf;
#else
static LHASH *empty_lhash;
#endif

rb_scan_args(argc, argv, "21", &oid, &value, &critical);
StringValue(oid);
StringValue(value);
if(NIL_P(critical)) critical = Qfalse;

nid = OBJ_ln2nid(RSTRING(oid)->ptr);
if(!nid) nid = OBJ_sn2nid(RSTRING(oid)->ptr);
if(!nid) ossl_raise(eX509ExtError, "unknown OID `%s'", RSTRING(oid)->ptr);
valstr = rb_str_new2(RTEST(critical) ? "critical," : "");
rb_str_append(valstr, value);
GetX509ExtFactory(self, ctx);
#ifdef HAVE_X509V3_EXT_NCONF_NID
rconf = rb_iv_get(self, "@config");
conf = NIL_P(rconf) ? NULL : GetConfigPtr(rconf);
ext = X509V3_EXT_nconf_nid(conf, ctx, nid, RSTRING(valstr)->ptr);
#else
if (!empty_lhash) empty_lhash = lh_new(NULL, NULL);
ext = X509V3_EXT_conf_nid(empty_lhash, ctx, nid, RSTRING(valstr)->ptr);
#endif
if (!ext){
ossl_raise(eX509ExtError, "%s = %s",
       RSTRING(oid)->ptr, RSTRING(value)->ptr);
}

#crl=Object

#issuer_certificate=Object

#subject_certificate=Object

#subject_request=Object