123456789_123456789_123456789_123456789_123456789_

Class: OpenSSL::X509::Revoked

Relationships & Source Files
Inherits: Object
Defined in: ext/openssl/ossl_x509revoked.c,
ext/openssl/lib/openssl/x509.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(*args)

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 101

static VALUE
ossl_x509revoked_initialize(int argc, VALUE *argv, VALUE self)
{
    /* EMPTY */
    return self;
}

Instance Attribute Details

#extensions (rw)

Gets X509v3 extensions as array of X509Ext objects

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 187

static VALUE
ossl_x509revoked_get_extensions(VALUE self)
{
    X509_REVOKED *rev;
    int count, i;
    X509_EXTENSION *ext;
    VALUE ary;

    GetX509Rev(self, rev);
    count = X509_REVOKED_get_ext_count(rev);
    if (count < 0) {
	OSSL_Debug("count < 0???");
	return rb_ary_new();
    }
    ary = rb_ary_new2(count);
    for (i=0; i<count; i++) {
	ext = X509_REVOKED_get_ext(rev, i);
	rb_ary_push(ary, ossl_x509ext_new(ext));
    }

    return ary;
}

#extensions=(ary) (rw)

Sets X509_EXTENSIONs

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 213

static VALUE
ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
{
    X509_REVOKED *rev;
    X509_EXTENSION *ext;
    long i;
    VALUE item;

    Check_Type(ary, T_ARRAY);
    for (i=0; i<RARRAY_LEN(ary); i++) {
	OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
    }
    GetX509Rev(self, rev);
    while ((ext = X509_REVOKED_delete_ext(rev, 0)))
	X509_EXTENSION_free(ext);
    for (i=0; i<RARRAY_LEN(ary); i++) {
	item = RARRAY_AREF(ary, i);
	ext = GetX509ExtPtr(item);
	if(!X509_REVOKED_add_ext(rev, ext, -1)) {
	    ossl_raise(eX509RevError, NULL);
	}
    }

    return ary;
}

#serial (rw)

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 127

static VALUE
ossl_x509revoked_get_serial(VALUE self)
{
    X509_REVOKED *rev;

    GetX509Rev(self, rev);

    return asn1integer_to_num(X509_REVOKED_get0_serialNumber(rev));
}

#serial=(num) (rw)

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 137

static VALUE
ossl_x509revoked_set_serial(VALUE self, VALUE num)
{
    X509_REVOKED *rev;
    ASN1_INTEGER *asn1int;

    GetX509Rev(self, rev);
    asn1int = num_to_asn1integer(num, NULL);
    if (!X509_REVOKED_set_serialNumber(rev, asn1int)) {
	ASN1_INTEGER_free(asn1int);
	ossl_raise(eX509RevError, "X509_REVOKED_set_serialNumber");
    }
    ASN1_INTEGER_free(asn1int);

    return num;
}

#time (rw)

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 154

static VALUE
ossl_x509revoked_get_time(VALUE self)
{
    X509_REVOKED *rev;
    const ASN1_TIME *time;

    GetX509Rev(self, rev);
    time = X509_REVOKED_get0_revocationDate(rev);
    if (!time)
	return Qnil;

    return asn1time_to_time(time);
}

#time=(time) (rw)

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 168

static VALUE
ossl_x509revoked_set_time(VALUE self, VALUE time)
{
    X509_REVOKED *rev;
    ASN1_TIME *asn1time;

    GetX509Rev(self, rev);
    asn1time = ossl_x509_time_adjust(NULL, time);
    if (!X509_REVOKED_set_revocationDate(rev, asn1time)) {
	ASN1_TIME_free(asn1time);
	ossl_raise(eX509RevError, "X509_REVOKED_set_revocationDate");
    }
    ASN1_TIME_free(asn1time);

    return time;
}

Instance Method Details

#==(other)

[ GitHub ]

  
# File 'ext/openssl/lib/openssl/x509.rb', line 354

def ==(other)
  return false unless Revoked === other
  to_der == other.to_der
end

#add_extension(ext)

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 239

static VALUE
ossl_x509revoked_add_extension(VALUE self, VALUE ext)
{
    X509_REVOKED *rev;

    GetX509Rev(self, rev);
    if (!X509_REVOKED_add_ext(rev, GetX509ExtPtr(ext), -1)) {
	ossl_raise(eX509RevError, NULL);
    }

    return ext;
}

#initialize_copy(other)

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 108

static VALUE
ossl_x509revoked_initialize_copy(VALUE self, VALUE other)
{
    X509_REVOKED *rev, *rev_other, *rev_new;

    rb_check_frozen(self);
    GetX509Rev(self, rev);
    GetX509Rev(other, rev_other);

    rev_new = X509_REVOKED_dup(rev_other);
    if (!rev_new)
	ossl_raise(eX509RevError, "X509_REVOKED_dup");

    SetX509Rev(self, rev_new);
    X509_REVOKED_free(rev);

    return self;
}

#to_der

[ GitHub ]

  
# File 'ext/openssl/ossl_x509revoked.c', line 252

static VALUE
ossl_x509revoked_to_der(VALUE self)
{
    X509_REVOKED *rev;
    VALUE str;
    int len;
    unsigned char *p;

    GetX509Rev(self, rev);
    len = i2d_X509_REVOKED(rev, NULL);
    if (len <= 0)
	ossl_raise(eX509RevError, "i2d_X509_REVOKED");
    str = rb_str_new(NULL, len);
    p = (unsigned char *)RSTRING_PTR(str);
    if (i2d_X509_REVOKED(rev, &p) <= 0)
	ossl_raise(eX509RevError, "i2d_X509_REVOKED");
    ossl_str_adjust(str, p);
    return str;
}