merge revision(s) 42126: [Backport #8664]

* ext/openssl/ossl_asn1.c (asn1time_to_time):  Implement YYMMDDhhmmZ
	  format for ASN.1 UTCTime.  [ruby-trunk - Bug #8664]

	* test/openssl/test_asn1.rb:  Test for the above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@42215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2013-07-28 12:49:00 +00:00
parent 589da706be
commit 0f1fb6ff36
4 changed files with 27 additions and 6 deletions

View file

@ -1,3 +1,9 @@
Sun Jul 28 21:44:57 2013 Eric Hodel <drbrain@segment7.net>
* ext/openssl/ossl_asn1.c (asn1time_to_time): Implement YYMMDDhhmmZ
format for ASN.1 UTCTime. [ruby-trunk - Bug #8664]
* test/openssl/test_asn1.rb: Test for the above.
Fri Jul 26 00:38:58 2013 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org> Fri Jul 26 00:38:58 2013 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
* lib/rubygems: Update to RubyGems 2.0.6. [ruby-core:56160] * lib/rubygems: Update to RubyGems 2.0.6. [ruby-core:56160]

View file

@ -33,15 +33,22 @@ asn1time_to_time(ASN1_TIME *time)
{ {
struct tm tm; struct tm tm;
VALUE argv[6]; VALUE argv[6];
int count;
if (!time || !time->data) return Qnil; if (!time || !time->data) return Qnil;
memset(&tm, 0, sizeof(struct tm)); memset(&tm, 0, sizeof(struct tm));
switch (time->type) { switch (time->type) {
case V_ASN1_UTCTIME: case V_ASN1_UTCTIME:
if (sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon, count = sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ",
&tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min,
ossl_raise(rb_eTypeError, "bad UTCTIME format"); &tm.tm_sec);
if (count == 5) {
tm.tm_sec = 0;
} else if (count != 6) {
ossl_raise(rb_eTypeError, "bad UTCTIME format: \"%s\"",
time->data);
} }
if (tm.tm_year < 69) { if (tm.tm_year < 69) {
tm.tm_year += 2000; tm.tm_year += 2000;

View file

@ -263,6 +263,14 @@ rEzBQ0F9dUyqQ9gyRg8KHhDfv9HzT1d/rnUZMkoombwYBRIUChGCYV0GnJcan2Zm
end end
end end
def test_decode_utctime
expected = Time.at 1374535380
assert_equal expected, OpenSSL::ASN1.decode("\x17\v1307222323Z").value
expected += 17
assert_equal expected, OpenSSL::ASN1.decode("\x17\r130722232317Z").value
end
def test_create_inf_length_primitive def test_create_inf_length_primitive
expected = %w{ 24 80 04 01 61 00 00 } expected = %w{ 24 80 04 01 61 00 00 }
raw = [expected.join('')].pack('H*') raw = [expected.join('')].pack('H*')

View file

@ -1,10 +1,10 @@
#define RUBY_VERSION "2.0.0" #define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-07-26" #define RUBY_RELEASE_DATE "2013-07-28"
#define RUBY_PATCHLEVEL 280 #define RUBY_PATCHLEVEL 281
#define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 7 #define RUBY_RELEASE_MONTH 7
#define RUBY_RELEASE_DAY 26 #define RUBY_RELEASE_DAY 28
#include "ruby/version.h" #include "ruby/version.h"