@@ -404,6 +404,9 @@ ossl_ocspreq_sign(int argc, VALUE *argv, VALUE self)
404404 * Verifies this request using the given _certificates_ and _store_.
405405 * _certificates_ is an array of OpenSSL::X509::Certificate, _store_ is an
406406 * OpenSSL::X509::Store.
407+ *
408+ * Note that +false+ is returned if the request does not have a signature.
409+ * Use #signed? to check whether the request is signed or not.
407410 */
408411
409412static VALUE
@@ -452,6 +455,22 @@ ossl_ocspreq_to_der(VALUE self)
452455 return str ;
453456}
454457
458+ /*
459+ * call-seq:
460+ * request.signed? -> true or false
461+ *
462+ * Returns +true+ if the request is signed, +false+ otherwise. Note that the
463+ * validity of the signature is *not* checked. Use #verify to verify that.
464+ */
465+ static VALUE
466+ ossl_ocspreq_signed_p (VALUE self )
467+ {
468+ OCSP_REQUEST * req ;
469+
470+ GetOCSPReq (self , req );
471+ return OCSP_request_is_signed (req ) ? Qtrue : Qfalse ;
472+ }
473+
455474/*
456475 * OCSP::Response
457476 */
@@ -1809,6 +1828,7 @@ Init_ossl_ocsp(void)
18091828 rb_define_method (cOCSPReq , "check_nonce" , ossl_ocspreq_check_nonce , 1 );
18101829 rb_define_method (cOCSPReq , "add_certid" , ossl_ocspreq_add_certid , 1 );
18111830 rb_define_method (cOCSPReq , "certid" , ossl_ocspreq_get_certid , 0 );
1831+ rb_define_method (cOCSPReq , "signed?" , ossl_ocspreq_signed_p , 0 );
18121832 rb_define_method (cOCSPReq , "sign" , ossl_ocspreq_sign , -1 );
18131833 rb_define_method (cOCSPReq , "verify" , ossl_ocspreq_verify , -1 );
18141834 rb_define_method (cOCSPReq , "to_der" , ossl_ocspreq_to_der , 0 );
0 commit comments