Class: CertificateAuthority::MemoryKeyMaterial
- Inherits:
-
Object
- Object
- CertificateAuthority::MemoryKeyMaterial
- Includes:
- KeyMaterial, Validations
- Defined in:
- lib/certificate_authority/key_material.rb
Instance Attribute Summary collapse
-
#keypair ⇒ Object
Returns the value of attribute keypair.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
Instance Method Summary collapse
- #generate_key(modulus_bits = 2048) ⇒ Object
-
#initialize ⇒ MemoryKeyMaterial
constructor
A new instance of MemoryKeyMaterial.
- #is_in_hardware? ⇒ Boolean
- #is_in_memory? ⇒ Boolean
- #validate ⇒ Object
Methods included from Validations
Methods included from KeyMaterial
from_x509_key_pair, from_x509_public_key
Constructor Details
#initialize ⇒ MemoryKeyMaterial
Returns a new instance of MemoryKeyMaterial.
47 48 |
# File 'lib/certificate_authority/key_material.rb', line 47 def initialize end |
Instance Attribute Details
#keypair ⇒ Object
Returns the value of attribute keypair.
43 44 45 |
# File 'lib/certificate_authority/key_material.rb', line 43 def keypair @keypair end |
#private_key ⇒ Object
Returns the value of attribute private_key.
44 45 46 |
# File 'lib/certificate_authority/key_material.rb', line 44 def private_key @private_key end |
#public_key ⇒ Object
Returns the value of attribute public_key.
45 46 47 |
# File 'lib/certificate_authority/key_material.rb', line 45 def public_key @public_key end |
Instance Method Details
#generate_key(modulus_bits = 2048) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/certificate_authority/key_material.rb', line 67 def generate_key(modulus_bits=2048) self.keypair = OpenSSL::PKey::RSA.new(modulus_bits) self.private_key = keypair self.public_key = keypair.public_key self.keypair end |
#is_in_hardware? ⇒ Boolean
59 60 61 |
# File 'lib/certificate_authority/key_material.rb', line 59 def is_in_hardware? false end |
#is_in_memory? ⇒ Boolean
63 64 65 |
# File 'lib/certificate_authority/key_material.rb', line 63 def is_in_memory? true end |
#validate ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/certificate_authority/key_material.rb', line 50 def validate if private_key.nil? errors.add :private_key, "cannot be blank" end if public_key.nil? errors.add :public_key, "cannot be blank" end end |