Class: OpenSSL::OCSP::Response (Ruby 2.2.2)
Description: Class : OpenSSL::OCSP::Response - Ruby 2.2.2

- Home
- Core 2.2.2
- Std-lib 2.2.2
- Downloads

Support for the Ruby 2.2 series has ended. See here for reference.

### Home Classes Methods

### In Files

- openssl/ossl_ns_spki.c

### Parent

Object

### Methods

- ::create
- ::new
- #basic
- #status
- #status_string
- #to_der

### Class/Module Index

Quicksearch

- Integer
- OpenSSL::ASN1
- OpenSSL::ASN1::ASN1Data
- OpenSSL::ASN1::ASN1Error
- OpenSSL::ASN1::Constructive
- OpenSSL::ASN1::ObjectId
- OpenSSL::ASN1::Primitive
- OpenSSL::BN
- OpenSSL::BNError
- OpenSSL::Buffering
- OpenSSL::Cipher
- OpenSSL::Cipher::Cipher
- OpenSSL::Cipher::CipherError
- OpenSSL::Config
- OpenSSL::ConfigError
- OpenSSL::Digest
- OpenSSL::Digest::DigestError
- OpenSSL::Engine
- OpenSSL::Engine::EngineError
- OpenSSL::HMAC
- OpenSSL::HMACError
- OpenSSL::Netscape
- OpenSSL::Netscape::SPKI
- OpenSSL::Netscape::SPKIError
- OpenSSL::OCSP
- OpenSSL::OCSP::BasicResponse
- OpenSSL::OCSP::CertificateId
- OpenSSL::OCSP::OCSPError
- OpenSSL::OCSP::Request
- OpenSSL::OCSP::Response
- OpenSSL::OpenSSLError
- OpenSSL::PKCS12
- OpenSSL::PKCS12::PKCS12Error
- OpenSSL::PKCS5
- OpenSSL::PKCS5::PKCS5Error
- OpenSSL::PKCS7
- OpenSSL::PKCS7::PKCS7Error
- OpenSSL::PKCS7::RecipientInfo
- OpenSSL::PKCS7::SignerInfo
- OpenSSL::PKey
- OpenSSL::PKey::DH
- OpenSSL::PKey::DHError
- OpenSSL::PKey::DSA
- OpenSSL::PKey::DSAError
- OpenSSL::PKey::EC
- OpenSSL::PKey::EC::Group
- OpenSSL::PKey::EC::Group::Error
- OpenSSL::PKey::EC::Point
- OpenSSL::PKey::EC::Point::Error
- OpenSSL::PKey::ECError
- OpenSSL::PKey::PKey
- OpenSSL::PKey::PKeyError
- OpenSSL::PKey::RSA
- OpenSSL::PKey::RSAError
- OpenSSL::Random
- OpenSSL::Random::RandomError
- OpenSSL::SSL
- OpenSSL::SSL::Nonblock
- OpenSSL::SSL::SSLContext
- OpenSSL::SSL::SSLError
- OpenSSL::SSL::SSLErrorWaitReadable
- OpenSSL::SSL::SSLErrorWaitWritable
- OpenSSL::SSL::SSLServer
- OpenSSL::SSL::SSLSocket
- OpenSSL::SSL::Session
- OpenSSL::SSL::Session::SessionError
- OpenSSL::SSL::SocketForwarder
- OpenSSL::X509
- OpenSSL::X509::Attribute
- OpenSSL::X509::AttributeError
- OpenSSL::X509::CRL
- OpenSSL::X509::CRLError
- OpenSSL::X509::Certificate
- OpenSSL::X509::CertificateError
- OpenSSL::X509::Extension
- OpenSSL::X509::ExtensionError
- OpenSSL::X509::ExtensionFactory
- OpenSSL::X509::Name
- OpenSSL::X509::Name::RFC2253DN
- OpenSSL::X509::NameError
- OpenSSL::X509::Request
- OpenSSL::X509::RequestError
- OpenSSL::X509::Revoked
- OpenSSL::X509::RevokedError
- OpenSSL::X509::Store
- OpenSSL::X509::StoreContext
- OpenSSL::X509::StoreError
- unknown

No matching classes.

# 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

OpenSSL::OCSP::Response.create(status, basic_response = nil) → response click to toggle source

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

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

        return obj;
    }

OpenSSL::OCSP::Response.new → response click to toggle source
OpenSSL::OCSP::Response.new(response_der) → response

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

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

        rb_scan_args(argc, argv, "01", &arg);
        if(!NIL_P(arg)){
            OCSP_RESPONSE *res = DATA_PTR(self), *x;
            arg = ossl_to_der_if_possible(arg);
            StringValue(arg);
            p = (unsigned char *)RSTRING_PTR(arg);
            x = d2i_OCSP_RESPONSE(&res, &p, RSTRING_LEN(arg));
            DATA_PTR(self) = res;
            if(!x){
                ossl_raise(eOCSPError, "cannot load DER encoded response");
            }
        }

        return self;
    }

### Public Instance Methods

basic click to toggle source

Returns a BasicResponse for this response

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

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

        return ret;
    }

status → Integer click to toggle source

Returns the status of the response.

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

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

        return INT2NUM(st);
    }

status_string → String click to toggle source

Returns a status string for the response.

                   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_der → String click to toggle source

Returns this response as a DER-encoded string.

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