Class: CertificateAuthority::Extensions::KeyUsage

Inherits:
Object
  • Object
show all
Includes:
ExtensionAPI
Defined in:
lib/certificate_authority/extensions.rb

Overview

Specifies the allowed usage purposes of the keypair specified in this certificate. Reference: Section 4.2.1.3 of RFC3280 tools.ietf.org/html/rfc3280#section-4.2.1.3

Note: OpenSSL when parsing an extension will return results in the form ‘Digital Signature’, but on signing you have to set it to ‘digitalSignature’. So copying an extension from an imported cert isn’t going to work yet.

Constant Summary collapse

OPENSSL_IDENTIFIER =
"keyUsage"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ExtensionAPI

#config_extensions

Constructor Details

#initializeKeyUsage

Returns a new instance of KeyUsage.



324
325
326
327
# File 'lib/certificate_authority/extensions.rb', line 324

def initialize
  @critical = false
  @usage = ["digitalSignature", "nonRepudiation"]
end

Instance Attribute Details

#criticalObject

Returns the value of attribute critical.



321
322
323
# File 'lib/certificate_authority/extensions.rb', line 321

def critical
  @critical
end

#usageObject

Returns the value of attribute usage.



322
323
324
# File 'lib/certificate_authority/extensions.rb', line 322

def usage
  @usage
end

Class Method Details

.parse(value, critical) ⇒ Object



343
344
345
346
347
348
349
# File 'lib/certificate_authority/extensions.rb', line 343

def self.parse(value, critical)
  obj = self.new
  return obj if value.nil?
  obj.critical = critical
  obj.usage = value.split(/,\s*/)
  obj
end

Instance Method Details

#==(o) ⇒ Object



339
340
341
# File 'lib/certificate_authority/extensions.rb', line 339

def ==(o)
  o.class == self.class && o.state == state
end

#openssl_identifierObject



329
330
331
# File 'lib/certificate_authority/extensions.rb', line 329

def openssl_identifier
  OPENSSL_IDENTIFIER
end

#to_sObject



333
334
335
336
337
# File 'lib/certificate_authority/extensions.rb', line 333

def to_s
  res = []
  res += @usage
  res.join(',')
end