Class: OpenSSL::OCSP::Response

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#OpenSSL::OCSP::Response.newObject #OpenSSL::OCSP::Response.new(response_der) ⇒ Object

Creates a new OpenSSL::OCSP::Response. The response may be created empty or from a response_der string.



545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
# File 'ext/openssl/ossl_ocsp.c', line 545

static VALUE
ossl_ocspres_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE arg;
    OCSP_RESPONSE *res, *res_new;
    const unsigned char *p;

    rb_scan_args(argc, argv, "01", &arg);
    if(!NIL_P(arg)){
	GetOCSPRes(self, res);
	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");
	SetOCSPRes(self, res_new);
	OCSP_RESPONSE_free(res);
    }

    return self;
}

Class Method Details

.OpenSSL::OCSP::Response.create(status, basic_response = nil) ⇒ Object

Creates an OpenSSL::OCSP::Response from status and basic_response.



485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'ext/openssl/ossl_ocsp.c', line 485

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 = NewOCSPRes(klass);
    if(!(res = OCSP_response_create(st, bs)))
	ossl_raise(eOCSPError, NULL);
    SetOCSPRes(obj, res);

    return obj;
}

Instance Method Details

#basicObject

Returns a BasicResponse for this response



613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
# File 'ext/openssl/ossl_ocsp.c', line 613

static VALUE
ossl_ocspres_get_basic(VALUE self)
{
    OCSP_RESPONSE *res;
    OCSP_BASICRESP *bs;
    VALUE ret;

    GetOCSPRes(self, res);
    ret = NewOCSPBasicRes(cOCSPBasicRes);
    if(!(bs = OCSP_response_get1_basic(res)))
	return Qnil;
    SetOCSPBasicRes(ret, bs);

    return ret;
}

#statusInteger

Returns the status of the response.

Returns:



575
576
577
578
579
580
581
582
583
584
585
# File 'ext/openssl/ossl_ocsp.c', line 575

static VALUE
ossl_ocspres_status(VALUE self)
{
    OCSP_RESPONSE *res;
    int st;

    GetOCSPRes(self, res);
    st = OCSP_response_status(res);

    return INT2NUM(st);
}

#status_stringString

Returns a status string for the response.

Returns:

  • (String)


594
595
596
597
598
599
600
601
602
603
604
# File 'ext/openssl/ossl_ocsp.c', line 594

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

#to_derString

Returns this response as a DER-encoded string.

Returns:

  • (String)


636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
# File 'ext/openssl/ossl_ocsp.c', line 636

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