Skip to content

fshin1988/ssl_certificate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SslCertificate

ssl_certificate is wrapper of OpenSSL::X509::Certificate.

It has some useful methods to handle ssl certificate.

Installation

Add this line to your application's Gemfile:

gem 'ssl_certificate'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ssl_certificate

Usage

require 'ssl_certificate'

# create object from certificate of pem or der format
cert_pem = File.read("spec/test_data/www.example.com.crt")
cert = SslCertificate::Certificate.new(cert_pem)

cert.common_name
# => "www.example.com"

cert.alternative_names
# => ["example.com", "hoge.example.com"]

key_pem = File.read("spec/test_data/www.example.com.key")
cert.check_private_key_str(key_pem)
# => true

# check whether a fqdn corresponds to the certificate
cert.check_fqdn("www.example.com")
# => true
cert.check_fqdn("hoge.example.com")
# => true

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fshin1988/ssl_certificate.

License

The gem is available as open source under the terms of the MIT License.