Class: OpenSSL::PKey::RSA
- Inherits:
-
Object
- Object
- OpenSSL::PKey::RSA
- Defined in:
- lib/postdb/helpers/openssl/pkey/rsa.rb
Class Method Summary collapse
-
.dump(object) ⇒ Object
Dump the object.
-
.load(object) ⇒ Object
Load the object.
Instance Method Summary collapse
-
#valid? ⇒ Boolean
Check if the RSA key is valid.
Class Method Details
.dump(object) ⇒ Object
Dump the object
Arguments:
object: (OpenSSL::PKey::RSA)
Example:
>> OpenSSL::PKey::RSA.dump(rsa)
=> "..."
14 15 16 17 18 19 20 |
# File 'lib/postdb/helpers/openssl/pkey/rsa.rb', line 14 def dump(object) unless object.is_a?(self) raise ActiveRecord::SerializationTypeMismatch, "Expected '#{self}' got '#{object.class}'." end object.to_der end |
.load(object) ⇒ Object
Load the object
Arguments:
object: (String)
Example:
>> OpenSSL::PKey::RSA.load(object)
=> #<OpenSSL::PKey::RSA:0x00000000000000>
31 32 33 34 35 |
# File 'lib/postdb/helpers/openssl/pkey/rsa.rb', line 31 def load(object) return nil unless object new(object) end |
Instance Method Details
#valid? ⇒ Boolean
Check if the RSA key is valid
Example:
>> key.valid?
=> true
44 45 46 47 48 49 50 51 52 |
# File 'lib/postdb/helpers/openssl/pkey/rsa.rb', line 44 def valid? begin self.class.new(self.to_der) rescue OpenSSL::PKey::RSAError => e return false end true end |