类 OpenSSL::OCSP::Response
一个 OpenSSL::OCSP::Response
包含证书检查的状态,该状态是从 OpenSSL::OCSP::Request
创建的。
公共类方法
OpenSSL::OCSP::Response.create(status, basic_response = nil) → response 点击切换源代码
从 status 和 basic_response 创建一个 OpenSSL::OCSP::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 */ obj = NewOCSPRes(klass); if(!(res = OCSP_response_create(st, bs))) ossl_raise(eOCSPError, NULL); SetOCSPRes(obj, res); return obj; }
OpenSSL::OCSP::Response.new → response 点击切换源代码
OpenSSL::OCSP::Response.new(response_der) → response
创建一个新的 OpenSSL::OCSP::Response
。响应可以为空创建,也可以从 response_der 字符串创建。
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; }
公共实例方法
basic 点击切换源代码
返回此响应的 BasicResponse
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; }
initialize_copy(p1) 点击切换源代码
static VALUE ossl_ocspres_initialize_copy(VALUE self, VALUE other) { OCSP_RESPONSE *res, *res_old, *res_new; rb_check_frozen(self); GetOCSPRes(self, res_old); GetOCSPRes(other, res); res_new = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_RESPONSE), res); if (!res_new) ossl_raise(eOCSPError, "ASN1_item_dup"); SetOCSPRes(self, res_new); OCSP_RESPONSE_free(res_old); return self; }
status → Integer 点击切换源代码
返回响应的状态。
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 点击切换源代码
返回响应的状态字符串。
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 点击切换源代码
将此响应作为 DER 编码的字符串返回。
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; }