Skip to content

Commit

Permalink
Convert asn_header string literal to ASCII-8BIT
Browse files Browse the repository at this point in the history
See issue #2
  • Loading branch information
edwardmp committed Dec 3, 2013
1 parent 79954e9 commit 247d5a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/transip.rb
Expand Up @@ -288,7 +288,13 @@ def signature(method, parameters, time, nonce)

digest = Digest::SHA512.new.digest(serialized_input)
asn_header = "\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40"
asn = asn_header + digest

# convert asn_header literal to ASCII-8BIT
if RUBY_VERSION.split('.')[0] == "2"
asn = asn_header.b + digest
else
asn = asn_header + digest
end
private_key = OpenSSL::PKey::RSA.new(@key)
encrypted_asn = private_key.private_encrypt(asn)
readable_encrypted_asn = Base64.encode64(encrypted_asn)
Expand Down

0 comments on commit 247d5a0

Please sign in to comment.