Module: JOSE::JWK::PEM

Extended by:
PEM
Included in:
PEM
Defined in:
lib/jose/jwk/pem.rb

Instance Method Summary collapse

Instance Method Details

#from_binary(object, password = nil) ⇒ Object


5
6
7
8
# File 'lib/jose/jwk/pem.rb', line 5

def from_binary(object, password = nil)
  pkey = OpenSSL::PKey.read(object, password)
  return JOSE::JWK::KTY.from_key(pkey)
end

#to_binary(key, password = nil) ⇒ Object


10
11
12
13
14
15
16
17
# File 'lib/jose/jwk/pem.rb', line 10

def to_binary(key, password = nil)
  if password
    cipher = OpenSSL::Cipher.new('DES-EDE3-CBC')
    return key.to_pem(cipher, password)
  else
    return key.to_pem
  end
end