diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-06-01 16:33:56 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-06-01 16:33:56 +0900 |
commit | dc2222fd8323d0c8cb74e25dad819ecdbdd99e2a (patch) | |
tree | 7a1aee21a017cfd9c51fbaee44193e7257044412 /ext/openssl/ossl_x509.c | |
parent | 17b3f3ed11660fd3adaf74ca7e13fdf83689a241 (diff) | |
download | ruby-dc2222fd8323d0c8cb74e25dad819ecdbdd99e2a.tar.gz |
openssl: fix the Year 2038 issuetopic/openssl-get-rid-of-time_t
The fix in r55219 was wrong. It fixed the issue only when long is 32bit
and also time_t is 64bit. But time_t may be 32bit. OpenSSL 1.0.0
introduced ASN1_TIME_adj() and X509_time_adj_ex() which takes offset
days. So make use of it.
Diffstat (limited to 'ext/openssl/ossl_x509.c')
-rw-r--r-- | ext/openssl/ossl_x509.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/openssl/ossl_x509.c b/ext/openssl/ossl_x509.c index cf62b53e28..e9a60b7f0a 100644 --- a/ext/openssl/ossl_x509.c +++ b/ext/openssl/ossl_x509.c @@ -15,6 +15,21 @@ VALUE mX509; #define DefX509Default(x,i) \ rb_define_const(mX509, "DEFAULT_" #x, rb_str_new2(X509_get_default_##i())) +ASN1_TIME * +ossl_x509_time_adjust(ASN1_TIME *s, VALUE time) +{ + time_t sec; + +#if defined(HAVE_ASN1_TIME_ADJ) + int off_days; + ossl_time_extract(time, &sec, &off_days); + return X509_time_adj_ex(s, off_days, 0, &sec); +#else + sec = time_to_time_t(time); + return X509_time_adj(s, 0, &sec); +#endif +} + void Init_ossl_x509(void) { |