class OpenSSL::PKey::RSA

Public Class Methods

dump(object) click to toggle source

Dump the object

Arguments:

object: (OpenSSL::PKey::RSA)

Example:

>> OpenSSL::PKey::RSA.dump(rsa)
=> "..."
# 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) click to toggle source

Load the object

Arguments:

object: (String)

Example:

>> OpenSSL::PKey::RSA.load(object)
=> #<OpenSSL::PKey::RSA:0x00000000000000>
# File lib/postdb/helpers/openssl/pkey/rsa.rb, line 31
def load(object)
  return nil unless object

  new(object)
end

Public Instance Methods

valid?() click to toggle source

Check if the RSA key is valid

Example:

>> key.valid?
=> true
# 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