diff options
author | mh <mh@immerda.ch> | 2016-11-10 02:03:43 +0100 |
---|---|---|
committer | mh <mh@immerda.ch> | 2016-11-10 02:03:43 +0100 |
commit | 58e13dbd417bfc0d4ca9712d0fe6e334992d0abc (patch) | |
tree | 5de50a9a9e12413a3f976aa2e45c3d8e11e9db5f | |
parent | 6deb959721ba5e90d876ff34343c0926730faf7b (diff) |
make the function still work with an ancient ruby version
-rw-r--r-- | lib/puppet/parser/functions/onion_address.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/onion_address.rb b/lib/puppet/parser/functions/onion_address.rb index a3db2f4..a6f9755 100644 --- a/lib/puppet/parser/functions/onion_address.rb +++ b/lib/puppet/parser/functions/onion_address.rb @@ -22,7 +22,9 @@ Returns the onionadress for that key, *without* the .onion suffix. # We can skip the first 22 bits of the der format as they are ignored by tor # https://timtaubert.de/blog/2014/11/using-the-webcrypto-api-to-generate-onion-names-for-tor-hidden-services/ # https://gitweb.torproject.org/torspec.git/tree/rend-spec.txt#n525 + # Except for Ruby 1.8.7 where the first 22 are not present at all + start = RUBY_VERSION.to_f < 1.9 ? 0 : 22 public_key_der = private_key.public_key.to_der - Base32.encode(Digest::SHA1.digest(public_key_der[22..-1]))[0..15].downcase + Base32.encode(Digest::SHA1.digest(public_key_der[start..-1]))[0..15].downcase end end |