Method: OpenSSL::Timestamp::Request#initialize

Defined in:
ext/openssl/ossl_ts.c

#initialize(*args) ⇒ Object

When creating a Request with the File or string parameter, the corresponding File or string must be DER-encoded.

call-seq:

OpenSSL::Timestamp::Request.new(file)    -> request
OpenSSL::Timestamp::Request.new(string)  -> request
OpenSSL::Timestamp::Request.new          -> empty request


193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'ext/openssl/ossl_ts.c', line 193

static VALUE
ossl_ts_req_initialize(int argc, VALUE *argv, VALUE self)
{
    TS_REQ *ts_req = DATA_PTR(self);
    BIO *in;
    VALUE arg;

    if(rb_scan_args(argc, argv, "01", &arg) == 0) {
        return self;
    }

    arg = ossl_to_der_if_possible(arg);
    in = ossl_obj2bio(&arg);
    ts_req = d2i_TS_REQ_bio(in, &ts_req);
    BIO_free(in);
    if (!ts_req)
        ossl_raise(eTimestampError, "Error when decoding the timestamp request");
    DATA_PTR(self) = ts_req;

    return self;
}