Class: Acme::Client::CertificateRequest

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/acme/client/certificate_request.rb

Defined Under Namespace

Classes: ECKeyPatch

Constant Summary collapse

DEFAULT_KEY_LENGTH =
2048
DEFAULT_DIGEST =
OpenSSL::Digest::SHA256
SUBJECT_KEYS =
{
  common_name:         'CN',
  country_name:        'C',
  organization_name:   'O',
  organizational_unit: 'OU',
  state_or_province:   'ST',
  locality_name:       'L'
}.freeze
SUBJECT_TYPES =
{
  'CN' => OpenSSL::ASN1::UTF8STRING,
  'C'  => OpenSSL::ASN1::UTF8STRING,
  'O'  => OpenSSL::ASN1::UTF8STRING,
  'OU' => OpenSSL::ASN1::UTF8STRING,
  'ST' => OpenSSL::ASN1::UTF8STRING,
  'L'  => OpenSSL::ASN1::UTF8STRING
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(common_name: nil, names: [], private_key: generate_private_key, subject: {}, digest: DEFAULT_DIGEST.new) ⇒ CertificateRequest

Returns a new instance of CertificateRequest.



28
29
30
31
32
33
34
35
36
37
# File 'lib/acme/client/certificate_request.rb', line 28

def initialize(common_name: nil, names: [], private_key: generate_private_key, subject: {}, digest: DEFAULT_DIGEST.new)
  @digest = digest
  @private_key = private_key
  @subject = normalize_subject(subject)
  @common_name = common_name || @subject[SUBJECT_KEYS[:common_name]] || @subject[:common_name]
  @names = names.to_a.dup
  normalize_names
  @subject[SUBJECT_KEYS[:common_name]] ||= @common_name
  validate_subject
end

Instance Attribute Details

#common_nameObject (readonly)

Returns the value of attribute common_name.



24
25
26
# File 'lib/acme/client/certificate_request.rb', line 24

def common_name
  @common_name
end

#namesObject (readonly)

Returns the value of attribute names.



24
25
26
# File 'lib/acme/client/certificate_request.rb', line 24

def names
  @names
end

#private_keyObject (readonly)

Returns the value of attribute private_key.



24
25
26
# File 'lib/acme/client/certificate_request.rb', line 24

def private_key
  @private_key
end

#subjectObject (readonly)

Returns the value of attribute subject.



24
25
26
# File 'lib/acme/client/certificate_request.rb', line 24

def subject
  @subject
end

Instance Method Details

#csrObject



39
40
41
# File 'lib/acme/client/certificate_request.rb', line 39

def csr
  @csr ||= generate
end