Method: PkernelJce::IdentityFactory#load

Defined in:
lib/pkernel_jce/identity.rb

#load(opts = {}, &block) ⇒ Object



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/pkernel_jce/identity.rb', line 362

def load(opts = {}, &block)

  format = opts[:format]
  case format
  when :pk8, :p8, :pkcs8
    res = load_pk8(opts, &block)
  when :pem
    res = load_pem(opts, &block)
  else
    res = load_keystore(opts, &block)
  end

  if res[:key].nil?
    raise Pkernel::Error, "Failed to load key from the store."
  end

  Pkernel::Identity.new( { privKey: res[:key], certificate: res[:cert], chain: res[:chain] } )
end