Class: ChefSSL::Client::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-ssl/client/request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, data, csr = nil) ⇒ Request



7
8
9
10
11
12
13
14
15
16
# File 'lib/chef-ssl/client/request.rb', line 7

def initialize(host, data, csr=nil)
  @host = host
  @csr = csr || EaSSL::SigningRequest.new.load(data['csr'])
  @type = data['type']
  @ca = data['ca']
  @id = data['id']
  @name = data['name']
  @key = data['key']
  @days = data['days'] || (365 * 5)
end

Instance Attribute Details

#caObject (readonly)

Returns the value of attribute ca.



5
6
7
# File 'lib/chef-ssl/client/request.rb', line 5

def ca
  @ca
end

#csrObject (readonly)

Returns the value of attribute csr.



5
6
7
# File 'lib/chef-ssl/client/request.rb', line 5

def csr
  @csr
end

#daysObject (readonly)

Returns the value of attribute days.



5
6
7
# File 'lib/chef-ssl/client/request.rb', line 5

def days
  @days
end

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/chef-ssl/client/request.rb', line 5

def host
  @host
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/chef-ssl/client/request.rb', line 5

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/chef-ssl/client/request.rb', line 5

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/chef-ssl/client/request.rb', line 5

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/chef-ssl/client/request.rb', line 5

def type
  @type
end

Class Method Details

.create(key, type, options) ⇒ Object



31
32
33
34
35
# File 'lib/chef-ssl/client/request.rb', line 31

def self.create(key, type, options)
  name = EaSSL::CertificateName.new(options)
  csr  = EaSSL::SigningRequest.new(:name => name, :key => key)
  self.new('localhost', { 'type' => type }, csr)
end

Instance Method Details

#issue_certificate(cert_text) ⇒ Object



26
27
28
29
# File 'lib/chef-ssl/client/request.rb', line 26

def issue_certificate(cert_text)
  cert = EaSSL::Certificate.new({}).load(cert_text)
  IssuedCertificate.new(self, cert)
end

#subjectObject



18
19
20
# File 'lib/chef-ssl/client/request.rb', line 18

def subject
  @csr.subject.to_s
end

#to_pemObject



22
23
24
# File 'lib/chef-ssl/client/request.rb', line 22

def to_pem
  @csr.to_pem
end