I'm trying to test the interoperability of openssl when used in Ruby on one side, and on the command line on the other side.
I generated a RSA certificate and extracted its public key this way:
openssl req -x509 -nodes -days 1825 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
openssl rsa -in mycert.pem -pubout > mycert.pub
I wrote a Ruby script that does 2 things:
- it encodes/decodes a test file with the public key first and then with the private key (using Base64 encoding on top of the RSA encoding to make network communication easier)
- it runs system commands to encrypt the same test file with the openssl command line tool
You can find the code of this Ruby script in the following Gist: https://gist.github.com/dirtyhenry/4673331 (cf. the poc-openssl-rsa.rb file)
My question is: how come my Ruby-generated public-encrypted.txt file is different from the public-encrypted-cl64.txt? Is it caused by some file-system side effects? (ie. one is a string when the other is a file or something?)
Thanks.