Closed
Description
Hey there,
I am trying to load a private ecdsa key (in pem format) to be used for signing. I was having several issues with my signed tokens, so I did some debugging. Here is a code snippet (using a throwaway private key):
require 'openssl'
key_string = "-----BEGIN EC PRIVATE KEY-----
MHcCAQEEINOov9ihnWNoJd5ER6kj0/b5ZvZkBycx8wxNA7N9e4FpoAoGCCqGSM49
AwEHoUQDQgAEB3tH41EaU+eT+R3GtPvLDR8GucWLQlouTX1lXFmEnOoeCITi/w4E
VUx6NAn7/Xve7pAOAPSt4fO+FLhPPTBmsQ==
-----END EC PRIVATE KEY-----"
original_key = OpenSSL::PKey::EC.new(key_string)
puts original_key.to_pem
Here, you would expect the output from original_key.to_pem
to match key_string
. This is the case in Ruby 2.3.0, but in JRuby 1.7.27 (and JRuby 9.2.7.0), this is what my output looks like:
-----BEGIN EC PRIVATE KEY-----
MCUCAQEEINOov9ihnWNoJd5ER6kj0/b5ZvZkBycx8wxNA7N9e4Fp
-----END EC PRIVATE KEY-----
I have been trying to figure out why this is happening for a while now, and I am stumped. Does anyone know what's going on, and how I can get it to work properly.
Thanks!
Metadata
Metadata
Assignees
Labels
No labels