mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-30 08:53:05 +00:00
auto import public key in mpw file
This commit is contained in:
parent
0bf8d4e4ba
commit
855640c932
1 changed files with 7 additions and 2 deletions
|
@ -45,7 +45,13 @@ class MPW
|
||||||
data = decrypt(f.read)
|
data = decrypt(f.read)
|
||||||
|
|
||||||
when /^wallet\/keys\/(?<key>.+)\.pub$/
|
when /^wallet\/keys\/(?<key>.+)\.pub$/
|
||||||
@keys[Regexp.last_match('key')] = f.read
|
key = Regexp.last_match('key')
|
||||||
|
|
||||||
|
if GPGME::Key.find(:public, key).length == 0
|
||||||
|
GPGME::Key.import(f.read, armor: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
@keys[key] = f.read
|
||||||
|
|
||||||
when /^wallet\/passwords\/(?<id>[a-zA-Z0-9]+)\.gpg$/
|
when /^wallet\/passwords\/(?<id>[a-zA-Z0-9]+)\.gpg$/
|
||||||
@passwords[Regexp.last_match('id')] = f.read
|
@passwords[Regexp.last_match('id')] = f.read
|
||||||
|
@ -143,7 +149,6 @@ class MPW
|
||||||
if not file.nil? and File.exists?(file)
|
if not file.nil? and File.exists?(file)
|
||||||
data = File.open(file).read
|
data = File.open(file).read
|
||||||
GPGME::Key.import(data, armor: true)
|
GPGME::Key.import(data, armor: true)
|
||||||
puts GPGME::Key.find(key)[0].trust
|
|
||||||
else
|
else
|
||||||
data = GPGME::Key.export(key, armor: true).read
|
data = GPGME::Key.export(key, armor: true).read
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue