aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-04-20 02:11:14 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-04-27 23:07:41 +0900
commit4c726635566caf0772f253baeb7b1b86b1711c8f (patch)
treecf4ca8bb9f3d6669049a3a9f9e0d33b3bdfe2acb
parent8e9419ba692c7c46ee80241571015f2069b7e47b (diff)
downloadruby-4c726635566caf0772f253baeb7b1b86b1711c8f.tar.gz
ext/openssl: disable OpenSSL::Random.pseudo_bytes if deprecated
-rw-r--r--ext/openssl/extconf.rb1
-rw-r--r--ext/openssl/ossl_rand.c4
2 files changed, 5 insertions, 0 deletions
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index 7ecb6a7..f2222c0 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -95,6 +95,7 @@ have_func("SSL_CTX_set_alpn_select_cb")
have_func("SSL_get_server_tmp_key", ["openssl/ssl.h"])
# added in 1.1.0
+have_func("RAND_pseudo_bytes", ["openssl/rand.h"], "-Werror=deprecated-declarations")
have_func("X509_STORE_get_ex_data")
have_func("X509_STORE_set_ex_data")
diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c
index daf866d..7058402 100644
--- a/ext/openssl/ossl_rand.c
+++ b/ext/openssl/ossl_rand.c
@@ -125,6 +125,7 @@ ossl_rand_bytes(VALUE self, VALUE len)
return str;
}
+#if defined(HAVE_RAND_PSEUDO_BYTES)
/*
* call-seq:
* pseudo_bytes(length) -> string
@@ -152,6 +153,7 @@ ossl_rand_pseudo_bytes(VALUE self, VALUE len)
return str;
}
+#endif
#ifdef HAVE_RAND_EGD
/*
@@ -225,7 +227,9 @@ Init_ossl_rand(void)
rb_define_module_function(mRandom, "load_random_file", ossl_rand_load_file, 1);
rb_define_module_function(mRandom, "write_random_file", ossl_rand_write_file, 1);
rb_define_module_function(mRandom, "random_bytes", ossl_rand_bytes, 1);
+#if defined(HAVE_RAND_PSEUDO_BYTES)
rb_define_module_function(mRandom, "pseudo_bytes", ossl_rand_pseudo_bytes, 1);
+#endif
#ifdef HAVE_RAND_EGD
rb_define_module_function(mRandom, "egd", ossl_rand_egd, 1);
rb_define_module_function(mRandom, "egd_bytes", ossl_rand_egd_bytes, 2);