Class: KeyHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/team-secrets/key_helper.rb

Class Method Summary collapse

Class Method Details

.getPublicKey(file_path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/team-secrets/key_helper.rb', line 3

def self.getPublicKey(file_path)

  key_string = File.read(file_path)

    if (key_string[0..7] == 'ssh-rsa ')
      # Test the file conversion
      unless system("ssh-keygen -f #{file_path} -e -m pem > /dev/null 2>&1")
        raise 'Could not convert ssh-rsa public key to PEM format for OpenSSL'
      end

      key_string = `ssh-keygen -f #{file_path} -e -m pem`
    end

    key_string

end