Method: OpenSSL::X509::Name#initialize
- Defined in:
- ossl_x509name.c
#X509::Name.new ⇒ Object #X509::Name.new(der) ⇒ Object #X509::Name.new(distinguished_name) ⇒ Object #X509::Name.new(distinguished_name, template) ⇒ Object
Creates a new Name.
A name may be created from a DER encoded string der, an Array representing a distinguished_name or a distinguished_name along with a template.
name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']]
name = OpenSSL::X509::Name.new name.to_der
See add_entry for a description of the distinguished_name Array’s contents
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'ossl_x509name.c', line 132 static VALUE ossl_x509name_initialize(int argc, VALUE *argv, VALUE self) { X509_NAME *name; VALUE arg, template; GetX509Name(self, name); if (rb_scan_args(argc, argv, "02", &arg, &template) == 0) { return self; } else { VALUE tmp = rb_check_array_type(arg); if (!NIL_P(tmp)) { VALUE args; if(NIL_P(template)) template = OBJECT_TYPE_TEMPLATE; args = rb_ary_new3(2, self, template); rb_block_call(tmp, rb_intern("each"), 0, 0, ossl_x509name_init_i, args); } else{ const unsigned char *p; VALUE str = ossl_to_der_if_possible(arg); X509_NAME *x; StringValue(str); p = (unsigned char *)RSTRING_PTR(str); x = d2i_X509_NAME(&name, &p, RSTRING_LEN(str)); DATA_PTR(self) = name; if(!x){ ossl_raise(eX509NameError, NULL); } } } return self; } |