diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-09-27 03:42:23 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2017-10-05 16:25:27 +0300 |
commit | 62d540340120baac7fa432108a7847cbc2a1cbe5 (patch) | |
tree | 5c7e624d5ed4ccb3b5efb8b18845fb44290e852d /lib | |
parent | 5ae8e3787afa309d4e563a3c17804ede828f7a5a (diff) |
Process and create subkeys when a new GPG key is created
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/gpg.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/gitlab/gpg.rb b/lib/gitlab/gpg.rb index 0d5039ddf5f..be22a9e0fe2 100644 --- a/lib/gitlab/gpg.rb +++ b/lib/gitlab/gpg.rb @@ -34,6 +34,27 @@ module Gitlab end end + def subkeys_from_key(key) + using_tmp_keychain do + fingerprints = CurrentKeyChain.fingerprints_from_key(key) + raw_keys = GPGME::Key.find(:public, fingerprints) + grouped_subkeys = Hash.new { |h, k| h[k] = [] } + + raw_keys.each_with_object(grouped_subkeys).each do |raw_key, subkeys| + primary_subkey_id = raw_key.primary_subkey.keyid + + raw_key.subkeys.each do |subkey| + # Skip if current subkey is a master key + next if primary_subkey_id == subkey.keyid + # Skip if it isn't a sign key + next if subkey.capability.exclude?(:sign) + + subkeys[primary_subkey_id] << { keyid: subkey.keyid, fingerprint: subkey.fingerprint } + end + end + end + end + def user_infos_from_key(key) using_tmp_keychain do fingerprints = CurrentKeyChain.fingerprints_from_key(key) |