Class: MyPKI::P12
Instance Attribute Summary
#options
Instance Method Summary
collapse
included, #initialize
Methods included from Prompter
#file_prompt, #pass_prompt, #prompter
Instance Method Details
8
9
10
11
12
|
# File 'lib/mypki/loaders/p12.rb', line 8
def configure config, path
if path.end_with? '.p12' or path.end_with? '.pfx'
config['p12'] = { 'path' => path }
end
end
|
#load(config) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/mypki/loaders/p12.rb', line 14
def load config
if config['p12']
p12 = File.read config['p12']['path']
begin
retriable do
password = config['p12']['password']
password ||= pass_prompt 'Enter P12 pass phrase:'
pki = OpenSSL::PKCS12.new(p12, password)
Instance.key, Instance.cert = pki.key, pki.certificate
end
rescue OpenSSL::PKCS12::PKCS12Error
fail "Error: bad password"
end
end
end
|