Class: OpenSSL::ASN1::ObjectId

Inherits:
Primitive show all
Defined in:
ext/rubysl/openssl/ossl_asn1.c,
ext/rubysl/openssl/ossl_asn1.c

Overview

Represents the primitive object id for OpenSSL::ASN1

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Primitive

#initialize, #to_der

Methods inherited from ASN1Data

#initialize, #to_der

Constructor Details

This class inherits a constructor from OpenSSL::ASN1::Primitive

Class Method Details

.OpenSSL::ASN1::ObjectId.register(object_id, short_name, long_name) ⇒ Object

This adds a new ObjectId to the internal tables. Where object_id is the numerical form, short_name is the short name, and long_name is the long name.

Returns true if successful. Raises an OpenSSL::ASN1::ASN1Error if it fails.



1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
# File 'ext/rubysl/openssl/ossl_asn1.c', line 1310

static VALUE
ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
{
    StringValueCStr(oid);
    StringValueCStr(sn);
    StringValueCStr(ln);

    if(!OBJ_create(RSTRING_PTR(oid), RSTRING_PTR(sn), RSTRING_PTR(ln)))
	ossl_raise(eASN1Error, NULL);

    return Qtrue;
}

Instance Method Details

#lnObject Also known as: long_name

long_name is an alias to ln



1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
# File 'ext/rubysl/openssl/ossl_asn1.c', line 1352

static VALUE
ossl_asn1obj_get_ln(VALUE self)
{
    VALUE val, ret = Qnil;
    int nid;

    val = ossl_asn1_get_value(self);
    if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef)
	ret = rb_str_new2(OBJ_nid2ln(nid));

    return ret;
}

#oidObject

The object identifier as a String, e.g. “1.2.3.4.5”



1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
# File 'ext/rubysl/openssl/ossl_asn1.c', line 1369

static VALUE
ossl_asn1obj_get_oid(VALUE self)
{
    VALUE val;
    ASN1_OBJECT *a1obj;
    char buf[128];

    val = ossl_asn1_get_value(self);
    a1obj = obj_to_asn1obj(val);
    OBJ_obj2txt(buf, sizeof(buf), a1obj, 1);
    ASN1_OBJECT_free(a1obj);

    return rb_str_new2(buf);
}

#snObject Also known as: short_name

short_name is an alias to sn



1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
# File 'ext/rubysl/openssl/ossl_asn1.c', line 1331

static VALUE
ossl_asn1obj_get_sn(VALUE self)
{
    VALUE val, ret = Qnil;
    int nid;

    val = ossl_asn1_get_value(self);
    if ((nid = OBJ_txt2nid(StringValueCStr(val))) != NID_undef)
	ret = rb_str_new2(OBJ_nid2sn(nid));

    return ret;
}