Sha256: 655d886f7f70091a21ae23ff2f2953e5f2e0322cd4e0c45306b17f7d52ea99ca

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 Bytes

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'r509'

if ARGV[0].nil?
  puts "CSR and certificate parsing using r509 v#{R509::VERSION}."
  puts "Usage: r509-parse <cert or csr>"
else
  begin
    csr = R509::CSR.load_from_file ARGV[0]
  rescue
  end
  if csr
    puts "Subject: #{csr.subject}"
    puts "Algorithm: #{csr.signature_algorithm}"
    puts "SAN Names: #{csr.san.names.map { |n| n.value }.join(" , ")}"
  else
    begin
      cert = R509::Cert.load_from_file ARGV[0]
    rescue
    end
    if cert
      puts "Subject: #{cert.subject}"
      puts "Issuer: #{cert.issuer}"
      puts "Algorithm: #{cert.signature_algorithm}"
      puts "SAN Names: #{cert.san.names.map { |n| n.value }.join(" , ")}" unless cert.san.nil?
      puts "Not Before: #{cert.not_before}"
      puts "Not After: #{cert.not_after}"
      puts "Serial (Hex): #{cert.hexserial}"
      puts "Serial (Decimal): #{cert.serial}"
    else
      puts "Failed to parse CSR or certificate"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
r509-1.0.1 bin/r509-parse
r509-1.0 bin/r509-parse