Class GPGME::Key
In: lib/gpgme/key.rb
ext/gpgme/gpgme_n.c
Parent: Object

The CTX argument can be `NULL’. In that case, `gpgme_wait’ waits

  for any context to complete its operation.

Methods

==   comment   delete!   email   expired   expires   export   export   find   fingerprint   get   import   inspect   name   primary_subkey   primary_uid   sha   to_s  

Included Modules

KeyCommon

Attributes

chain_id  [R] 
issuer_name  [R] 
issuer_serial  [R] 
keylist_mode  [R] 
owner_trust  [R] 
protocol  [R] 
subkeys  [R] 
uids  [R] 

Public Class methods

Exports public keys

  GPGME::Key.export pattern, options

Private keys cannot be exported due to GPGME restrictions.

@param pattern

  Identifier of the key to export.

@param [Hash] options

  * +:output+ specify where to write the key to. It will be converted to
    a {GPGME::Data}, so it could be a file, for example.
  * Any other option accepted by {GPGME::Ctx.new}

@return [GPGME::Data] the exported key.

@example

  key = GPGME::Key.export "mrsimo@example.com"

@example writing to a file

  out = File.open("my.key", "w+")
  GPGME::Key.export "mrsimo@example.com", :output => out

Returns an array of {GPGME::Key} objects that match the parameters.

  • secret set to +:secret+ to get only secret keys, or to +:public+ to get only public keys.
  • keys_or_names an array or an item that can be either {GPGME::Key} elements, or string identifiers like the email or the sha. Leave blank to get all.
  • purposes get only keys that are usable for any of these purposes. See {GPGME::Key} for a list of possible key capabilities.

@example

  GPGME::Key.find :secret # => first secret key found

@example

  GPGME::Key.find(:public, "mrsimo@example.com")
  # => return only public keys that match mrsimo@example.com

@example

  GPGME::Key.find(:public, "mrsimo@example.com", :sign)
  # => return the public keys that match mrsimo@example.com and are
  #    capable of signing

Imports a key

  GPGME::Key.import keydata, options

@param keydata

  The key to import. It will be converted to a {GPGME::Data} object,
  so could be a file, for example.

@param options

  Any other option accepted by {GPGME::Ctx.new}

@example

  GPGME::Key.import(File.open("my.key"))

Public Instance methods

Returns the issuer comment for this key.

Delete this key. If it‘s public, and has a secret one it will fail unless allow_secret is specified as true.

Returns the email for this key.

Returns true if the key is expired

Returns the expiry date for this key

Exports this key. Accepts the same options as {GPGME::Ctx.new}, and +options[:output]+, where you can specify something that can become a {GPGME::Data}, where the output will go.

@example

  key.export(:armor => true)
  # => GPGME::Data you can read with ASCII armored format

@example

  file = File.open("key.asc", "w+")
  key.export(:output => file)
  # => the key will be written to the file.

Longer descriptive value. Can be used to identify the key.

Returns the issuer name for this key.

Returns the main {GPGME::UserID} for this key.

Short descriptive value. Can be used to identify the key.

[Validate]