class Gem::Commands::CheckcertCommand

Gem command to display the certificate of a gem, if any.

Constants

VERSION

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/rubygems/commands/checkcert_command.rb, line 16
def initialize
  super("checkcert", "Display the certificate of a gem's signature, if any.",
        :domain => :local, :version => Gem::Requirement.default)

  add_version_option
  add_local_remote_options
end

Public Instance Methods

check_certificate() click to toggle source
# File lib/rubygems/commands/checkcert_command.rb, line 36
def check_certificate
  gem, specs = get_one_gem_name, []

  dep = Gem::Dependency.new gem, options[:version]

  if local? then
    if File.exist? gem then
      specs << Gem::Package.new(gem).spec # rescue nil
    else
      specs.push(*dep.matching_specs)
    end
  end

  if remote? then
    abort "rubygems sucks and doesn't include the cert info..."
  end

  if specs.empty? then
    alert_error "Unknown gem '#{gem}'"
    terminate_interaction 1
  end

  spec = specs.last
  cert = spec.cert_chain.join

  unless cert.empty? then
    IO.popen("openssl x509 -noout -text", "w+") do |io|
      io.puts cert
      puts io.read
    end
  else
    alert_error "Gem '#{gem}' is not signed"
    terminate_interaction 1
  end
end
Also aliased as: execute
execute()
Alias for: check_certificate