Skip to content

Commit f2d0046

Browse files
nobuxtkoba (Tee KOBAYASHI)
and
xtkoba (Tee KOBAYASHI)
committed
Fixed the results of OpenSSL::Timestamp::Response#failure_info
Made stored values `Symbol`s instead of `ID`s. Fixes https://bugs.ruby-lang.org/issues/17625 Co-Authored-By: xtkoba (Tee KOBAYASHI) <[email protected]>
1 parent fd39183 commit f2d0046

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

ext/openssl/ossl_ts.c

+11-11
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)
@@ -1247,24 +1247,24 @@ Init_ossl_ts(void)
12471247
* timestamp server rejects the message imprint algorithm used in the
12481248
* +Request+
12491249
*/
1250-
sBAD_ALG = rb_intern_const("BAD_ALG");
1250+
sBAD_ALG = ID2SYM(rb_intern_const("BAD_ALG"));
12511251

12521252
/*
12531253
* Possible return value for +Response#failure_info+. Indicates that the
12541254
* timestamp server was not able to process the +Request+ properly.
12551255
*/
1256-
sBAD_REQUEST = rb_intern_const("BAD_REQUEST");
1256+
sBAD_REQUEST = ID2SYM(rb_intern_const("BAD_REQUEST"));
12571257
/*
12581258
* Possible return value for +Response#failure_info+. Indicates that the
12591259
* timestamp server was not able to parse certain data in the +Request+.
12601260
*/
1261-
sBAD_DATA_FORMAT = rb_intern_const("BAD_DATA_FORMAT");
1261+
sBAD_DATA_FORMAT = ID2SYM(rb_intern_const("BAD_DATA_FORMAT"));
12621262

1263-
sTIME_NOT_AVAILABLE = rb_intern_const("TIME_NOT_AVAILABLE");
1264-
sUNACCEPTED_POLICY = rb_intern_const("UNACCEPTED_POLICY");
1265-
sUNACCEPTED_EXTENSION = rb_intern_const("UNACCEPTED_EXTENSION");
1266-
sADD_INFO_NOT_AVAILABLE = rb_intern_const("ADD_INFO_NOT_AVAILABLE");
1267-
sSYSTEM_FAILURE = rb_intern_const("SYSTEM_FAILURE");
1263+
sTIME_NOT_AVAILABLE = ID2SYM(rb_intern_const("TIME_NOT_AVAILABLE"));
1264+
sUNACCEPTED_POLICY = ID2SYM(rb_intern_const("UNACCEPTED_POLICY"));
1265+
sUNACCEPTED_EXTENSION = ID2SYM(rb_intern_const("UNACCEPTED_EXTENSION"));
1266+
sADD_INFO_NOT_AVAILABLE = ID2SYM(rb_intern_const("ADD_INFO_NOT_AVAILABLE"));
1267+
sSYSTEM_FAILURE = ID2SYM(rb_intern_const("SYSTEM_FAILURE"));
12681268

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

test/openssl/test_ts.rb

+5
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ def test_response_creation
222222
assert_equal(token.to_der, resp.token.to_der)
223223
end
224224

225+
def test_response_failure_info
226+
resp = OpenSSL::Timestamp::Response.new("0\"0 \x02\x01\x020\x17\f\x15Invalid TimeStampReq.\x03\x02\x06\x80")
227+
assert_equal(:BAD_ALG, resp.failure_info)
228+
end
229+
225230
def test_response_mandatory_fields
226231
fac = OpenSSL::Timestamp::Factory.new
227232
req = OpenSSL::Timestamp::Request.new

0 commit comments

Comments
 (0)