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::Name.new
X509::Name.new => name
X509::Name.new(der) => name
X509::Name.new(distinguished_name) => name
X509::Name.new(distinguished_name, template) => name
ext/openssl/ossl_x509name.c
View on GitHub ↗
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;
}
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.
Example
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