Class: Bullion::Models::Certificate
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Bullion::Models::Certificate
- Defined in:
- lib/bullion/models/certificate.rb
Overview
SSL Certificate model
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_csr(csr) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bullion/models/certificate.rb', line 25 def self.from_csr(csr) subjt = csr.subject if csr.subject && !csr.subject.to_s.empty? cert = new( csr_fingerprint: Base64.encode64(OpenSSL::Digest::SHA1.digest(csr.to_pem)).chomp ) cert.subject = subjt if subjt cert end |
Instance Method Details
#cn ⇒ Object
21 22 23 |
# File 'lib/bullion/models/certificate.rb', line 21 def cn subject.split("/").grep(/^CN=/).first.split("=").last end |
#fingerprint ⇒ Object
17 18 19 |
# File 'lib/bullion/models/certificate.rb', line 17 def fingerprint Base64.encode64(OpenSSL::Digest::SHA1.digest(data)) end |
#init_values ⇒ Object
13 14 15 |
# File 'lib/bullion/models/certificate.rb', line 13 def init_values self.serial ||= SecureRandom.hex(4).to_i(16) end |