Method: Gem::Commands::CertCommand#load_default_key

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

#load_default_keyObject



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/rubygems/commands/cert_command.rb', line 261

def load_default_key
  key_file = File.join Gem.default_key_path
  key = File.read key_file
  passphrase = ENV["GEM_PRIVATE_KEY_PASSPHRASE"]
  options[:key] = OpenSSL::PKey.read key, passphrase
rescue Errno::ENOENT
  alert_error \
    "--private-key not specified and ~/.gem/gem-private_key.pem does not exist"

  terminate_interaction 1
rescue OpenSSL::PKey::PKeyError
  alert_error \
    "--private-key not specified and ~/.gem/gem-private_key.pem is not valid"

  terminate_interaction 1
end