mirror of
https://github.com/zammad/zammad
synced 2026-05-24 09:48:36 +00:00
38 lines
919 B
Ruby
38 lines
919 B
Ruby
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
|
|
|
module SecureMailing::PGP::Tool::Key
|
|
extend ActiveSupport::Concern
|
|
|
|
include SecureMailing::PGP::Tool::Exec
|
|
|
|
included do
|
|
|
|
def import(key)
|
|
gpg('import', stdin: key)
|
|
end
|
|
|
|
def export(fingerprint, passphrase = nil, secret: false)
|
|
options = %w[
|
|
--export-options export-minimal
|
|
--armor
|
|
]
|
|
command = secret ? 'export-secret-key' : 'export'
|
|
|
|
result = gpg(command, options: options, arguments: [fingerprint], passphrase: passphrase)
|
|
return result if result.stdout.present?
|
|
|
|
error_export!(result.stderr, secret)
|
|
|
|
result
|
|
end
|
|
|
|
def passphrase(fingerprint, passphrase)
|
|
options = %w[--dry-run]
|
|
|
|
result = gpg('passwd', options: options, arguments: [fingerprint], passphrase: passphrase)
|
|
error_passphrase!(result.stderr)
|
|
|
|
result
|
|
end
|
|
end
|
|
end
|