class OpenSSL::OCSP::Response
An OpenSSL::OCSP::Response contains the status of a certificate check which is created from an OpenSSL::OCSP::Request.
Public Class Methods
static VALUE
ossl_ocspres_s_create(VALUE klass, VALUE status, VALUE basic_resp)
{
OCSP_BASICRESP *bs;
OCSP_RESPONSE *res;
VALUE obj;
int st = NUM2INT(status);
if(NIL_P(basic_resp)) bs = NULL;
else GetOCSPBasicRes(basic_resp, bs); /* NO NEED TO DUP */
obj = ossl_ocspres_alloc(klass);
if (!(res = OCSP_response_create(st, bs)))
ossl_raise(eOCSPError, "OCSP_response_create");
RTYPEDDATA_DATA(obj) = res;
return obj;
}
Creates an OpenSSL::OCSP::Response from status and basic_response.
static VALUE
ossl_ocspres_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE arg;
OCSP_RESPONSE *res_new;
const unsigned char *p;
rb_scan_args(argc, argv, "01", &arg);
ossl_want_uninitialized(self, &ossl_ocsp_response_type);
if (NIL_P(arg)) {
res_new = OCSP_RESPONSE_new();
if (!res_new)
ossl_raise(eOCSPError, "OCSP_RESPONSE_new");
}
else {
arg = ossl_to_der_if_possible(arg);
StringValue(arg);
p = (unsigned char *)RSTRING_PTR(arg);
res_new = d2i_OCSP_RESPONSE(NULL, &p, RSTRING_LEN(arg));
if (!res_new)
ossl_raise(eOCSPError, "d2i_OCSP_RESPONSE");
}
RTYPEDDATA_DATA(self) = res_new;
return self;
}
Creates a new OpenSSL::OCSP::Response. The response may be created empty or from a response_der string.
Public Instance Methods
Source
static VALUE
ossl_ocspres_get_basic(VALUE self)
{
OCSP_RESPONSE *res;
OCSP_BASICRESP *bs;
VALUE ret;
GetOCSPRes(self, res);
ret = ossl_ocspbres_alloc(cOCSPBasicRes);
if (!(bs = OCSP_response_get1_basic(res)))
return Qnil;
RTYPEDDATA_DATA(ret) = bs;
return ret;
}
Returns a BasicResponse for this response
Source
static VALUE
ossl_ocspres_status(VALUE self)
{
OCSP_RESPONSE *res;
int st;
GetOCSPRes(self, res);
st = OCSP_response_status(res);
return INT2NUM(st);
}
Returns the status of the response.
Source
static VALUE
ossl_ocspres_status_string(VALUE self)
{
OCSP_RESPONSE *res;
int st;
GetOCSPRes(self, res);
st = OCSP_response_status(res);
return rb_str_new2(OCSP_response_status_str(st));
}
Returns a status string for the response.
Source
static VALUE
ossl_ocspres_to_der(VALUE self)
{
OCSP_RESPONSE *res;
VALUE str;
long len;
unsigned char *p;
GetOCSPRes(self, res);
if((len = i2d_OCSP_RESPONSE(res, NULL)) <= 0)
ossl_raise(eOCSPError, NULL);
str = rb_str_new(0, len);
p = (unsigned char *)RSTRING_PTR(str);
if(i2d_OCSP_RESPONSE(res, &p) <= 0)
ossl_raise(eOCSPError, NULL);
ossl_str_adjust(str, p);
return str;
}
Returns this response as a DER-encoded string.