OpenSSL verify certificate from own CA

B

Bruno Antunes

Hello all and thanks for your time reading this.

I need to verify certificates issued by my own CA, for which I have a
certificate. How can I do the equivalent to openssl's

openssl verify -CAfile <cafile.pem> <certificate-to-verify.pem>

in Ruby code? The RDoc for OpenSSL is not very helpful in this regard.
I've tried:

Code:
require 'openssl'

ca = OpenSSL::X509::Certificate.new(File.read('ca-cert.pem'))

lic = OpenSSL::X509::Certificate.new(File.read('cert.pem'))

puts lic.verify( ca )

but I get:

test.rb:7:in `verify': wrong argument (OpenSSL::X509::Certificate)!
(Expected kind of OpenSSL::pKey::pKey) (TypeError)
from test.rb:7

I can't even find "verify" in the OpenSSL Rdoc at
http://www.ruby-doc.org/stdlib/libdoc/openssl/rdoc/index.html.

Any help is appreciated. Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top