summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-05-23 14:40:20 +0900
committernagachika <nagachika@ruby-lang.org>2021-05-23 14:40:20 +0900
commitfc73fc79cbaee6674256589b7cfe53d20b638a05 (patch)
tree9b1af3cc6d19947f18587170c9cd189a2b5f257e
parentf9196de1dee6f5ab8b6fe115070b92775a3500fe (diff)
merge revision(s) 1ad222477344597038d7ec08885a41f547c2a3b4: [Backport #17625]
[ruby/openssl] 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) <xtkoba+ruby@gmail.com> https://github.com/ruby/openssl/commit/f2d004679a --- ext/openssl/ossl_ts.c | 22 +++++++++++----------- test/openssl/test_ts.rb | 5 +++++ 2 files changed, 16 insertions(+), 11 deletions(-)
-rw-r--r--ext/openssl/ossl_ts.c22
-rw-r--r--test/openssl/test_ts.rb5
-rw-r--r--version.h2
3 files changed, 17 insertions, 12 deletions
diff --git a/ext/openssl/ossl_ts.c b/ext/openssl/ossl_ts.c
index d3209c3d40..692c0d620f 100644
--- a/ext/openssl/ossl_ts.c
+++ b/ext/openssl/ossl_ts.c
@@ -68,9 +68,9 @@ static VALUE cTimestampRequest;
static VALUE cTimestampResponse;
static VALUE cTimestampTokenInfo;
static VALUE cTimestampFactory;
-static ID sBAD_ALG, sBAD_REQUEST, sBAD_DATA_FORMAT, sTIME_NOT_AVAILABLE;
-static ID sUNACCEPTED_POLICY, sUNACCEPTED_EXTENSION, sADD_INFO_NOT_AVAILABLE;
-static ID sSYSTEM_FAILURE;
+static VALUE sBAD_ALG, sBAD_REQUEST, sBAD_DATA_FORMAT, sTIME_NOT_AVAILABLE;
+static VALUE sUNACCEPTED_POLICY, sUNACCEPTED_EXTENSION, sADD_INFO_NOT_AVAILABLE;
+static VALUE sSYSTEM_FAILURE;
static void
ossl_ts_req_free(void *ptr)
@@ -1247,24 +1247,24 @@ Init_ossl_ts(void)
* timestamp server rejects the message imprint algorithm used in the
* +Request+
*/
- sBAD_ALG = rb_intern_const("BAD_ALG");
+ sBAD_ALG = ID2SYM(rb_intern_const("BAD_ALG"));
/*
* Possible return value for +Response#failure_info+. Indicates that the
* timestamp server was not able to process the +Request+ properly.
*/
- sBAD_REQUEST = rb_intern_const("BAD_REQUEST");
+ sBAD_REQUEST = ID2SYM(rb_intern_const("BAD_REQUEST"));
/*
* Possible return value for +Response#failure_info+. Indicates that the
* timestamp server was not able to parse certain data in the +Request+.
*/
- sBAD_DATA_FORMAT = rb_intern_const("BAD_DATA_FORMAT");
+ sBAD_DATA_FORMAT = ID2SYM(rb_intern_const("BAD_DATA_FORMAT"));
- sTIME_NOT_AVAILABLE = rb_intern_const("TIME_NOT_AVAILABLE");
- sUNACCEPTED_POLICY = rb_intern_const("UNACCEPTED_POLICY");
- sUNACCEPTED_EXTENSION = rb_intern_const("UNACCEPTED_EXTENSION");
- sADD_INFO_NOT_AVAILABLE = rb_intern_const("ADD_INFO_NOT_AVAILABLE");
- sSYSTEM_FAILURE = rb_intern_const("SYSTEM_FAILURE");
+ sTIME_NOT_AVAILABLE = ID2SYM(rb_intern_const("TIME_NOT_AVAILABLE"));
+ sUNACCEPTED_POLICY = ID2SYM(rb_intern_const("UNACCEPTED_POLICY"));
+ sUNACCEPTED_EXTENSION = ID2SYM(rb_intern_const("UNACCEPTED_EXTENSION"));
+ sADD_INFO_NOT_AVAILABLE = ID2SYM(rb_intern_const("ADD_INFO_NOT_AVAILABLE"));
+ sSYSTEM_FAILURE = ID2SYM(rb_intern_const("SYSTEM_FAILURE"));
/* Document-class: OpenSSL::Timestamp
* Provides classes and methods to request, create and validate
diff --git a/test/openssl/test_ts.rb b/test/openssl/test_ts.rb
index 6e9c30894b..8e31a7d28d 100644
--- a/test/openssl/test_ts.rb
+++ b/test/openssl/test_ts.rb
@@ -222,6 +222,11 @@ _end_of_pem_
assert_equal(token.to_der, resp.token.to_der)
end
+ def test_response_failure_info
+ resp = OpenSSL::Timestamp::Response.new("0\"0 \x02\x01\x020\x17\f\x15Invalid TimeStampReq.\x03\x02\x06\x80")
+ assert_equal(:BAD_ALG, resp.failure_info)
+ end
+
def test_response_mandatory_fields
fac = OpenSSL::Timestamp::Factory.new
req = OpenSSL::Timestamp::Request.new
diff --git a/version.h b/version.h
index f85ff90aa4..0e9aef521d 100644
--- a/version.h
+++ b/version.h
@@ -12,7 +12,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 2
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 83
+#define RUBY_PATCHLEVEL 84
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 5