Reputation: 1639
I have generated a public/private keypair with OpenSSL. I want to use the private key now to sign my message using OpenSSL, and I was thinking to stay in a bash environment. I am required to use SHA-RSA1.
So far, I was suggested the following code but I am not happy with it:
openssl.exe dgst -sha1 -sign C:\...\path\to\key\privatekey.pem -binary C:\...\path\to\message\message.txt
I don't want to have my message be stored in a file (message.txt) to generate a signature and in any case, I would need to use openssl base64
afterwards to get the base64 representation.
Is there a more proper way to achieve what I want (and a one liner would be great)?
Upvotes: 4
Views: 4356
Reputation: 12672
Use openssl itself to encode base64
echo "$msg" | openssl dgst ... -binary | openssl enc -base64
Upvotes: 5