Skip to content

Commit d60ded5

Browse files
nobuxtkoba (Tee KOBAYASHI)
authored andcommitted
Fixed the results of OpenSSL::Timestamp::Response#failure_info
[ This is a backport to the 2.2 branch. ] Made stored values `Symbol`s instead of `ID`s. Fixes https://bugs.ruby-lang.org/issues/17625 Co-Authored-By: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com> (cherry picked from commit f2d0046)
1 parent 74d0cde commit d60ded5

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

ext/openssl/ossl_ts.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ static VALUE cTimestampRequest;
6868
static VALUE cTimestampResponse;
6969
static VALUE cTimestampTokenInfo;
7070
static VALUE cTimestampFactory;
71-
static ID sBAD_ALG, sBAD_REQUEST, sBAD_DATA_FORMAT, sTIME_NOT_AVAILABLE;
72-
static ID sUNACCEPTED_POLICY, sUNACCEPTED_EXTENSION, sADD_INFO_NOT_AVAILABLE;
73-
static ID sSYSTEM_FAILURE;
71+
static VALUE sBAD_ALG, sBAD_REQUEST, sBAD_DATA_FORMAT, sTIME_NOT_AVAILABLE;
72+
static VALUE sUNACCEPTED_POLICY, sUNACCEPTED_EXTENSION, sADD_INFO_NOT_AVAILABLE;
73+
static VALUE sSYSTEM_FAILURE;
7474

7575
static void
7676
ossl_ts_req_free(void *ptr)
@@ -1257,24 +1257,24 @@ Init_ossl_ts(void)
12571257
* timestamp server rejects the message imprint algorithm used in the
12581258
* +Request+
12591259
*/
1260-
sBAD_ALG = rb_intern_const("BAD_ALG");
1260+
sBAD_ALG = ID2SYM(rb_intern_const("BAD_ALG"));
12611261

12621262
/*
12631263
* Possible return value for +Response#failure_info+. Indicates that the
12641264
* timestamp server was not able to process the +Request+ properly.
12651265
*/
1266-
sBAD_REQUEST = rb_intern_const("BAD_REQUEST");
1266+
sBAD_REQUEST = ID2SYM(rb_intern_const("BAD_REQUEST"));
12671267
/*
12681268
* Possible return value for +Response#failure_info+. Indicates that the
12691269
* timestamp server was not able to parse certain data in the +Request+.
12701270
*/
1271-
sBAD_DATA_FORMAT = rb_intern_const("BAD_DATA_FORMAT");
1271+
sBAD_DATA_FORMAT = ID2SYM(rb_intern_const("BAD_DATA_FORMAT"));
12721272

1273-
sTIME_NOT_AVAILABLE = rb_intern_const("TIME_NOT_AVAILABLE");
1274-
sUNACCEPTED_POLICY = rb_intern_const("UNACCEPTED_POLICY");
1275-
sUNACCEPTED_EXTENSION = rb_intern_const("UNACCEPTED_EXTENSION");
1276-
sADD_INFO_NOT_AVAILABLE = rb_intern_const("ADD_INFO_NOT_AVAILABLE");
1277-
sSYSTEM_FAILURE = rb_intern_const("SYSTEM_FAILURE");
1273+
sTIME_NOT_AVAILABLE = ID2SYM(rb_intern_const("TIME_NOT_AVAILABLE"));
1274+
sUNACCEPTED_POLICY = ID2SYM(rb_intern_const("UNACCEPTED_POLICY"));
1275+
sUNACCEPTED_EXTENSION = ID2SYM(rb_intern_const("UNACCEPTED_EXTENSION"));
1276+
sADD_INFO_NOT_AVAILABLE = ID2SYM(rb_intern_const("ADD_INFO_NOT_AVAILABLE"));
1277+
sSYSTEM_FAILURE = ID2SYM(rb_intern_const("SYSTEM_FAILURE"));
12781278

12791279
/* Document-class: OpenSSL::Timestamp
12801280
* Provides classes and methods to request, create and validate

test/openssl/test_ts.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ def test_response_creation
228228
assert_equal(token.to_der, resp.token.to_der)
229229
end
230230

231+
def test_response_failure_info
232+
resp = OpenSSL::Timestamp::Response.new("0\"0 \x02\x01\x020\x17\f\x15Invalid TimeStampReq.\x03\x02\x06\x80")
233+
assert_equal(:BAD_ALG, resp.failure_info)
234+
end
235+
231236
def test_response_mandatory_fields
232237
fac = OpenSSL::Timestamp::Factory.new
233238
req = OpenSSL::Timestamp::Request.new

0 commit comments

Comments
 (0)