class Ronin::CLI::Commands::CertDump

Prints information for SSL/TLS certificates.

## Usage

ronin cert-dump [options] {HOST:PORT | URL | FILE} ...

## Options

-f, --file FILE                  Optional file to read values from
-C, --common-name                Only prints the Common Name (CN)
-A, --subject-alt-names          Only prints the subjectAltNames
-E, --extensions                 Print all certificate extensions
-h, --help                       Print help information

## Arguments

HOST:PORT | URL | FILE ...       A HOST:PORT, URL, or cert FILE

## Examples

ronin cert-dump ssl.crt
ronin cert-dump github.com:443
ronin cert-dump https://github.com/
ronin cert-dump -C 93.184.216.34:443
ronin cert-dump -A wired.com:443

Public Instance Methods

grab_cert(host,port) click to toggle source

Gets the certs from the host and port, and then print it.

@param [String] host

@param [Integer] port

@since 2.1.0

# File lib/ronin/cli/commands/cert_dump.rb, line 134
def grab_cert(host,port)
  cert = Support::Network::SSL.get_cert(host,port)

  print_cert(cert)
end
print_cert(cert) click to toggle source

Prints the certificate.

@param [Ronin::Support::Crypto::Cert] cert

print_cert_name(name) click to toggle source

Prints the X509 name.

@param [Ronin::Support::Crypto::Cert::Name] name

print_extension(ext) click to toggle source

Prints a certificate extension.

@param [OpenSSL::X509::Extension] ext

print_extensions(cert) click to toggle source

Prints the certificates extensions.

@param [Ronin::Support::Crypto::Cert] cert

print_full_cert(cert) click to toggle source

Prints the full verbose information about the certificate.

@param [Ronin::Support::Crypto::Cert] cert

print_public_key(public_key) click to toggle source

Prints the public key.

@param [OpenSSL::PKey::RSA, OpenSSL::PKey::EC] public_key

process_value(value) click to toggle source

Runs the ‘ronin cert-dump` command.

@param [String] value

The `HOST:PORT`, `URL`, or `FILE` value to process.
# File lib/ronin/cli/commands/cert_dump.rb, line 103
def process_value(value)
  case value
  when /\A[^:]+:\d+\z/
    host, port = host_and_port(value)

    grab_cert(host,port)
  when /\Ahttps:/
    host, port = host_and_port_from_url(value)

    grab_cert(host,port)
  else
    unless File.file?(value)
      print_error "no such file or directory: #{value}"
      exit(1)
    end

    cert = Support::Crypto::Cert.load_file(value)

    print_cert(cert)
  end
end