The Ruby/OpenSSL library is pretty poorly documented but you can pretty
much read it off the OpenSSL library's API. To sign a document you have
to pass in the hash algorithm to use and the text to be signed into the
private key object's sign method:

example:

# pkey is our private key
pkey = OpenSSL::PKey::RSA.generate(1024)
pub = pkey.public_key

# text is our text to be signed
text = "Hello, World!"

signature = pkey.sign(OpenSSL::Digest::SHA1.new, text)

if pub.verify(OpenSSL::Digest::SHA1.new, signature, text)
  puts "It works!"
else
  puts "S#%t! It failed!"
end

Damjan Rems wrote:
> Is it possible with Ruby to go through XML security process.
>
> - read x509 private key
> - read receiver x509 public key
> - encrypt message with private key
> - encrypt message with public key
> - sign message
>
> I guess first 4 steps could be made with openSSL library (found example
> in forum) but how to create a signature.
>
> I would realy like to see some example code.
>
> Thank you
> 
> TheR
> 
> 
> -- 
> Posted via http://www.ruby-forum.com/.