aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGOTOU Yuuzou <gotoyuzo@notwork.org>2002-07-23 10:45:25 +0000
committerGOTOU Yuuzou <gotoyuzo@notwork.org>2002-07-23 10:45:25 +0000
commit9dab048c26f6b039a31d5d3030bf0c35af39f831 (patch)
tree5fc940cdf35b0858db8102a1338794303c73edb1
parent95ca93a514b493ac6e93838d3f06a1c592b078a2 (diff)
downloadruby-openssl-history-9dab048c26f6b039a31d5d3030bf0c35af39f831.tar.gz
* ossl.h: include <openssl/e_os.h>
* ossl.c: workaround to convert into UTC time. * lib/openssl.rb: fix string embeded expression.
-rw-r--r--ChangeLog5
-rw-r--r--lib/openssl.rb2
-rw-r--r--ossl.c18
-rw-r--r--ossl.h1
4 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 07298c7..80e8466 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,11 @@ Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
All rights reserved.
$Log$
+Revision 1.38 2002/07/23 10:45:25 gotoyuzo
+* ossl.h: include <openssl/e_os.h>
+* ossl.c: workaround to convert into UTC time.
+* lib/openssl.rb: fix string embeded expression.
+
Revision 1.37 2002/04/07 16:35:32 majkl
* Macros fixups
* X509ExtFactory cleanup
diff --git a/lib/openssl.rb b/lib/openssl.rb
index d182220..4203d2a 100644
--- a/lib/openssl.rb
+++ b/lib/openssl.rb
@@ -284,7 +284,7 @@ end # defined? DH
return if arg.nil?
t = arg.class
while t
- method = "from_#{t.name.downcase.split("::").last}".intern
+ method = "from_#{t.name.downcase.split('::').last}".intern
return send(method, arg, type) if respond_to?(method, true)
t = t.superclass
end
diff --git a/ossl.c b/ossl.c
index d46547f..25a8a03 100644
--- a/ossl.c
+++ b/ossl.c
@@ -54,7 +54,11 @@ VALUE
asn1time_to_time(ASN1_UTCTIME *time)
{
struct tm tm;
+ time_t t;
+ char env[16];
+ const char *tz;
+ memset(&tm, 0, sizeof(struct tm));
switch(time->type) {
case V_ASN1_UTCTIME:
if (!strptime(time->data, "%y%m%d%H%M%SZ", &tm)) {
@@ -69,8 +73,18 @@ asn1time_to_time(ASN1_UTCTIME *time)
default:
rb_raise(rb_eTypeError, "unknown time format");
}
- /*return rb_time_new(mktime(gmtime(mktime(&tm))), 0); * Is this correct? */
- return rb_time_new(mktime(&tm), 0); /* or this one? */
+
+ /* workaround to convert into UTC time */
+ tz = getenv("TZ");
+ putenv("TZ=UTC0");
+ t = mktime(&tm);
+ if(!tz) unsetenv("TZ");
+ else {
+ snprintf(env, sizeof(env), "TZ=%s", tz);
+ putenv(env);
+ }
+
+ return rb_time_new(t, 0);
}
/*
diff --git a/ossl.h b/ossl.h
index 19b5c28..7a807ee 100644
--- a/ossl.h
+++ b/ossl.h
@@ -25,6 +25,7 @@ extern "C" {
#include <openssl/ssl.h>
#include <openssl/hmac.h>
#include <openssl/rand.h>
+#include <openssl/e_os.h>
#if defined(NT)
# undef OpenFile
#endif