Class: OpenSSL::X509::Revoked

Inherits:
Object
  • Object
show all
Defined in:
ext/openssl/ossl_x509revoked.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object



105
106
107
108
109
110
# File 'ext/openssl/ossl_x509revoked.c', line 105

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

Instance Method Details

#add_extension(ext) ⇒ Object



239
240
241
242
243
244
245
246
247
248
249
250
# 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;
}

#extensionsObject

Gets X509v3 extensions as array of X509Ext objects



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# 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) ⇒ Object

Sets X509_EXTENSIONs



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# 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;
}

#serialObject



131
132
133
134
135
136
137
138
139
# File 'ext/openssl/ossl_x509revoked.c', line 131

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) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'ext/openssl/ossl_x509revoked.c', line 141

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;
}

#timeObject



158
159
160
161
162
163
164
165
166
# File 'ext/openssl/ossl_x509revoked.c', line 158

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

    GetX509Rev(self, rev);

    return asn1time_to_time(X509_REVOKED_get0_revocationDate(rev));
}

#time=(time) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# 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;
}