Class: EaSSL::CertificateAuthority
- Inherits:
-
Object
- Object
- EaSSL::CertificateAuthority
- Defined in:
- lib/eassl/certificate_authority.rb
Overview
- Author
-
Paul Nicholson ([email protected])
- Co-Author
-
Adam Williams ([email protected])
- Copyright
-
Copyright © 2006 WebPower Design
- License
-
Distributes under the same terms as Ruby
Instance Attribute Summary collapse
-
#certificate ⇒ Object
readonly
Returns the value of attribute certificate.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#serial ⇒ Object
readonly
Returns the value of attribute serial.
Class Method Summary collapse
Instance Method Summary collapse
- #create_certificate(signing_request, type = 'server', days_valid = nil) ⇒ Object
-
#initialize(options = {}) ⇒ CertificateAuthority
constructor
A new instance of CertificateAuthority.
Constructor Details
#initialize(options = {}) ⇒ CertificateAuthority
Returns a new instance of CertificateAuthority.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/eassl/certificate_authority.rb', line 10 def initialize( = {}) if [:key] && [:certificate] && [:serial] @key = [:key] @certificate = [:certificate] @serial = [:serial] else [:name] ||= {} @key = Key.new({:password => 'ca_ssl_password'}.update()) @certificate = AuthorityCertificate.new(:key => @key, :name => [:name]) @serial = Serial.new(:next => 1) end end |
Instance Attribute Details
#certificate ⇒ Object (readonly)
Returns the value of attribute certificate.
9 10 11 |
# File 'lib/eassl/certificate_authority.rb', line 9 def certificate @certificate end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
9 10 11 |
# File 'lib/eassl/certificate_authority.rb', line 9 def key @key end |
#serial ⇒ Object (readonly)
Returns the value of attribute serial.
9 10 11 |
# File 'lib/eassl/certificate_authority.rb', line 9 def serial @serial end |
Class Method Details
.load(options) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/eassl/certificate_authority.rb', line 23 def self.load() key = Key.load(File.join([:ca_path], 'cakey.pem'), [:ca_password]) certificate = AuthorityCertificate.load(File.join([:ca_path], 'cacert.pem')) serial = Serial.load(File.join([:ca_path], 'serial.txt')) self.new(:key => key, :certificate => certificate, :serial => serial) end |
Instance Method Details
#create_certificate(signing_request, type = 'server', days_valid = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/eassl/certificate_authority.rb', line 30 def create_certificate(signing_request, type='server', days_valid=nil) = { :signing_request => signing_request, :ca_certificate => @certificate, :serial => @serial.issue_serial, :type => type } if days_valid [:days_valid] = days_valid end cert = Certificate.new() @serial.save! cert.sign(@key) cert end |