summaryrefslogtreecommitdiff
path: root/app/models/key.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/key.rb')
-rw-r--r--app/models/key.rb20
1 files changed, 4 insertions, 16 deletions
diff --git a/app/models/key.rb b/app/models/key.rb
index e2e59296eed..016eee86992 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -16,7 +16,6 @@ require 'digest/md5'
class Key < ActiveRecord::Base
include Sortable
- include Gitlab::Popen
belongs_to :user
@@ -79,20 +78,9 @@ class Key < ActiveRecord::Base
def generate_fingerprint
self.fingerprint = nil
- return unless key.present?
-
- cmd_status = 0
- cmd_output = ''
- Tempfile.open('gitlab_key_file') do |file|
- file.puts key
- file.rewind
- cmd_output, cmd_status = popen(%W(ssh-keygen -lf #{file.path}), '/tmp')
- end
-
- if cmd_status.zero?
- cmd_output.gsub /(\h{2}:)+\h{2}/ do |match|
- self.fingerprint = match
- end
- end
+
+ return unless self.key.present?
+
+ self.fingerprint = Gitlab::KeyFingerprint.new(self.key).fingerprint
end
end