I’ve run into a problem using openssl and ruby, which I can’t solve.
I have a public key, a text string, and a signature, and I want to check
that the signature was created from the text string using the
appropriate private key.
On the command line i can do
openssl sha1 -sha512 -verify /tmp/public.pem -signature
and I get ‘Verified OK’
I want to do the same in ruby. I can create the hash ok, but when I run
p pkey.verify( OpenSSL::Digest::SHA512.new, signatureValue,
I get ‘false’
Examining the key, I notice that before it is loaded into the OpenSSL
object the key reads
-----BEGIN PUBLIC KEY-----
but when I print the key out after creating the OpenSSL object i get
-----BEGIN RSA PUBLIC KEY-----
ie a chunk (MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8) has gone missing from the
front of the key. I guess this might be the source of my problem, but
try as I might I can’t find anything about what is going on here. I’m
no great SSL expert, and I’d love to get this done before christmas, so
if anyone can help it would really be appreciated.