Permalink
Browse files

Fallback to Ruby's pseudo random number generator if the system does …

…not have SHA512 installed.
  • Loading branch information...
1 parent de8b008 commit 0a94f16b9532894aeb7aed2aec5082dd3b521414 @josh josh committed Apr 22, 2008
Showing with 6 additions and 1 deletion.
  1. +6 −1 railties/lib/rails_generator/secret_key_generator.rb
@@ -76,7 +76,12 @@ def generate_secret_with_openssl
OpenSSL::Random.seed(rand(0).to_s + Time.now.usec.to_s)
end
data = OpenSSL::BN.rand(2048, -1, false).to_s
- return OpenSSL::Digest::SHA512.new(data).hexdigest
+
+ if OpenSSL::OPENSSL_VERSION_NUMBER > 0x00908000
+ OpenSSL::Digest::SHA512.new(data).hexdigest
+ else
+ generate_secret_with_prng
+ end
end
# Generate a random secret key with /dev/urandom.

0 comments on commit 0a94f16

Please sign in to comment.