Method: Gem::Commands::CertCommand#build_key

Defined in:
lib/rubygems/commands/cert_command.rb

#build_keyObject

:nodoc:



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/rubygems/commands/cert_command.rb', line 167

def build_key # :nodoc:
  return options[:key] if options[:key]

  passphrase = ask_for_password "Passphrase for your Private Key:"
  say "\n"

  passphrase_confirmation = ask_for_password "Please repeat the passphrase for your Private Key:"
  say "\n"

  raise Gem::CommandLineError,
        "Passphrase and passphrase confirmation don't match" unless passphrase == passphrase_confirmation

  algorithm = options[:key_algorithm] || Gem::Security::DEFAULT_KEY_ALGORITHM
  key = Gem::Security.create_key(algorithm)
  key_path = Gem::Security.write key, "gem-private_key.pem", 0o600, passphrase

  [key, key_path]
end