lib/ronin/cli/commands/cert_dump.rb in ronin-2.0.0 vs lib/ronin/cli/commands/cert_dump.rb in ronin-2.0.1
- old
+ new
@@ -15,10 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Ronin. If not, see <https://www.gnu.org/licenses/>.
#
require 'ronin/cli/value_processor_command'
+require 'ronin/cli/host_and_port'
require 'ronin/support/crypto/cert'
require 'ronin/support/network/ssl/mixin'
require 'command_kit/printing/indent'
require 'command_kit/printing/fields'
@@ -60,10 +61,11 @@
include Support::Network::SSL::Mixin
include CommandKit::Printing::Indent
include CommandKit::Printing::Fields
include CommandKit::Printing::Lists
+ include HostAndPort
usage '[options] {HOST:PORT | URL | FILE} ...'
option :common_name, short: '-C',
desc: 'Only prints the Common Name (CN)'
@@ -98,18 +100,15 @@
# The `HOST:PORT`, `URL`, or `FILE` value to process.
#
def process_value(value)
case value
when /\A[^:]+:\d+\z/
- host, port = value.split(':',2)
- port = port.to_i
+ host, port = host_and_port(value)
print_cert(ssl_cert(host,port))
when /\Ahttps:/
- uri = URI.parse(value)
- host = uri.host
- port = uri.port
+ host, port = host_and_port_from_url(value)
print_cert(ssl_cert(host,port))
else
unless File.file?(value)
print_error "no such file or directory: #{value}"
@@ -177,11 +176,9 @@
indent do
print_cert_name(cert.issuer)
end
puts
-
- fields = {}
if options[:extensions]
puts "Extensions:"
indent do
print_extensions(cert)