Class: EaSSL::SigningRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/eassl/signing_request.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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SigningRequest

Returns a new instance of SigningRequest.



9
10
11
12
13
14
15
# File 'lib/eassl/signing_request.rb', line 9

def initialize(options = {})
  @options = {
    :name       => {},                #required, CertificateName
    :key        => nil,               #required
  }.update(options)
  @options[:key] ||= Key.new(@options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object

This method is used to intercept and pass-thru calls to openSSL methods and instance variables.



34
35
36
# File 'lib/eassl/signing_request.rb', line 34

def method_missing(method)
  ssl.send(method)
end

Class Method Details

.load(pem_file_path) ⇒ Object



38
39
40
# File 'lib/eassl/signing_request.rb', line 38

def self.load(pem_file_path)
  new.load(File.read(pem_file_path))
end

Instance Method Details

#keyObject



28
29
30
# File 'lib/eassl/signing_request.rb', line 28

def key
  @options[:key]
end

#load(pem_string) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/eassl/signing_request.rb', line 42

def load(pem_string)
  begin
    @ssl = OpenSSL::X509::Request.new(pem_string)
  rescue
    raise "SigningRequestLoader: Error loading signing request"
  end
  self
end

#sslObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/eassl/signing_request.rb', line 17

def ssl
  unless @ssl
    @ssl = OpenSSL::X509::Request.new
    @ssl.version = 0
    @ssl.subject = CertificateName.new(@options[:name]).ssl
    @ssl.public_key = key.public_key
    @ssl.sign(key.private_key, OpenSSL::Digest::MD5.new)
  end
  @ssl
end