# OpenSSL verify certificate from own CA

**URL:** <https://www.ruby-forum.com/t/openssl-verify-certificate-from-own-ca/164366>\
**Category:** Ruby\
**Created:** [March 31, 2009, 3:50pm UTC](https://www.ruby-forum.com/t/openssl-verify-certificate-from-own-ca/164366 "2009-03-31T15:50:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![beer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f04885/32.png) [@beer](https://www.ruby-forum.com/u/beer)\
**Post date:** [March 31, 2009, 3:50pm UTC](https://www.ruby-forum.com/t/openssl-verify-certificate-from-own-ca/164366/1 "2009-03-31T15:50:46Z")

</div>

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:

```auto
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](http://www.ruby-doc.org/stdlib/libdoc/openssl/rdoc/index.html).

Any help is appreciated. Thanks again!
