Sha256: 925133d12aac69ae7ec7fa86ec5430e0d34773c309aab914511e0753ec9883a9

Contents?: true

Size: 986 Bytes

Versions: 1

Compression:

Stored size: 986 Bytes

Contents

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

if ARGV[0].nil? then
  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 not csr.nil?
    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 not cert.nil?
      puts "Subject: #{cert.subject}"
      puts "Issuer: #{cert.issuer}"
      puts "Algorithm: #{cert.signature_algorithm}"
      puts "SAN Names: #{cert.san.names.map { |n| n.value }.join(" , ")}"
      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

1 entries across 1 versions & 1 rubygems

Version Path
r509-0.9 bin/r509-parse