Class: OpenSSL::X509::ExtensionFactory
Relationships & Source Files | |
Inherits: | Object |
Defined in: | ext/openssl/ossl_x509ext.c, ext/openssl/lib/openssl/x509.rb |
Class Method Summary
- .new(*args) constructor
Instance Attribute Summary
- #crl=(crl) writeonly
- #issuer_certificate=(cert) writeonly
- #subject_certificate=(cert) writeonly
- #subject_request=(req) writeonly
Instance Method Summary
-
#create_ext(ln_or_sn, "value", critical = false) ⇒ X509::Extension
Creates a new
Extension
with passed values. - #create_ext_from_array(ary)
- #create_ext_from_hash(hash)
-
#create_ext_from_string(str)
“oid = critical, value”.
- #create_extension(*arg)
Constructor Details
.new(*args)
[ GitHub ]# File 'ext/openssl/ossl_x509ext.c', line 174
static VALUE ossl_x509extfactory_initialize(int argc, VALUE *argv, VALUE self) { /*X509V3_CTX *ctx;*/ VALUE issuer_cert, subject_cert, subject_req, crl; /*GetX509ExtFactory(self, ctx);*/ rb_scan_args(argc, argv, "04", &issuer_cert, &subject_cert, &subject_req, &crl); if (!NIL_P(issuer_cert)) ossl_x509extfactory_set_issuer_cert(self, issuer_cert); if (!NIL_P(subject_cert)) ossl_x509extfactory_set_subject_cert(self, subject_cert); if (!NIL_P(subject_req)) ossl_x509extfactory_set_subject_req(self, subject_req); if (!NIL_P(crl)) ossl_x509extfactory_set_crl(self, crl); return self; }
Instance Attribute Details
#crl=(crl) (writeonly)
[ GitHub ]# File 'ext/openssl/ossl_x509ext.c', line 162
static VALUE ossl_x509extfactory_set_crl(VALUE self, VALUE crl) { X509V3_CTX *ctx; GetX509ExtFactory(self, ctx); rb_iv_set(self, "@crl", crl); ctx->crl = GetX509CRLPtr(crl); /* NO DUP NEEDED */ return crl; }
#issuer_certificate=(cert) (writeonly)
[ GitHub ]# File 'ext/openssl/ossl_x509ext.c', line 126
static VALUE ossl_x509extfactory_set_issuer_cert(VALUE self, VALUE cert) { X509V3_CTX *ctx; GetX509ExtFactory(self, ctx); rb_iv_set(self, "@issuer_certificate", cert); ctx->issuer_cert = GetX509CertPtr(cert); /* NO DUP NEEDED */ return cert; }
#subject_certificate=(cert) (writeonly)
[ GitHub ]# File 'ext/openssl/ossl_x509ext.c', line 138
static VALUE ossl_x509extfactory_set_subject_cert(VALUE self, VALUE cert) { X509V3_CTX *ctx; GetX509ExtFactory(self, ctx); rb_iv_set(self, "@subject_certificate", cert); ctx->subject_cert = GetX509CertPtr(cert); /* NO DUP NEEDED */ return cert; }
#subject_request=(req) (writeonly)
[ GitHub ]# File 'ext/openssl/ossl_x509ext.c', line 150
static VALUE ossl_x509extfactory_set_subject_req(VALUE self, VALUE req) { X509V3_CTX *ctx; GetX509ExtFactory(self, ctx); rb_iv_set(self, "@subject_request", req); ctx->subject_req = GetX509ReqPtr(req); /* NO DUP NEEDED */ return req; }
Instance Method Details
#create_ext(ln_or_sn, "value", critical = false) ⇒ X509::Extension
#create_ext(ln_or_sn, "critical,value") ⇒ X509::Extension
Creates a new Extension
with passed values. See also x509v3_config(5).
# File 'ext/openssl/ossl_x509ext.c', line 203
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; VALUE rconf; CONF *conf; const char *oid_cstr = NULL; rb_scan_args(argc, argv, "21", &oid, &value, &critical); StringValue(value); if(NIL_P(critical)) critical = Qfalse; oid_cstr = StringValueCStr(oid); nid = OBJ_ln2nid(oid_cstr); if (nid != NID_undef) oid_cstr = OBJ_nid2sn(nid); valstr = rb_str_new2(RTEST(critical) ? "critical," : ""); rb_str_append(valstr, value); StringValueCStr(valstr); GetX509ExtFactory(self, ctx); obj = NewX509Ext(cX509Ext); rconf = rb_iv_get(self, "@config"); conf = NIL_P(rconf) ? NULL : GetConfig(rconf); X509V3_set_nconf(ctx, conf); #if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_IS_LIBRESSL ext = X509V3_EXT_nconf(conf, ctx, oid_cstr, RSTRING_PTR(valstr)); #else ext = X509V3_EXT_nconf(conf, ctx, (char *)oid_cstr, RSTRING_PTR(valstr)); #endif X509V3_set_ctx_nodb(ctx); if (!ext){ ossl_raise(eX509ExtError, "%"PRIsVALUE" = %"PRIsVALUE, oid, valstr); } SetX509Ext(obj, ext); return obj; }
#create_ext_from_array(ary)
# File 'ext/openssl/lib/openssl/x509.rb', line 28
def create_ext_from_array(ary) raise ExtensionError, "unexpected array form" if ary.size > 3 create_ext(ary[0], ary[1], ary[2]) end
#create_ext_from_hash(hash)
[ GitHub ]# File 'ext/openssl/lib/openssl/x509.rb', line 40
def create_ext_from_hash(hash) create_ext(hash["oid"], hash["value"], hash["critical"]) end
#create_ext_from_string(str)
“oid = critical, value”
# File 'ext/openssl/lib/openssl/x509.rb', line 33
def create_ext_from_string(str) # "oid = critical, value" oid, value = str.split(/=/, 2) oid.strip! value.strip! create_ext(oid, value) end
#create_extension(*arg)
[ GitHub ]# File 'ext/openssl/lib/openssl/x509.rb', line 20
def create_extension(*arg) if arg.size > 1 create_ext(*arg) else send("create_ext_from_"+arg[0].class.name.downcase, arg[0]) end end