Sha256: e351bc5576d5053fcf6be18b0d822f681ca9ae1d217c4fed04202e6626590a07

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

#!/usr/bin/env ruby

require 'bundler/setup'
require 'optparse'
require 'ostruct'

require 'cryptorecord/tlsa'

options = OpenStruct.new

##### DEFAULTS ####
options.selector = 0
options.usage = 3
options.mtype = 0
###################

OptionParser.new do |opt|
  opt.banner = "Usage: #{$PROGRAM_NAME} [ options ]"
  opt.on('-h', '--help', 'This help screen') do
    warn opt
    exit
  end
  opt.on('-f', '--certfile CERTIFICATE-FILE',
         'Certificatefile') { |o| options.certfile = o }
  opt.on('-H', '--host HOST', 'host') { |o| options.host = o }
  opt.on('-p', '--port PORTNUMBER', 'port') { |o| options.port = o }
  opt.on('-P', '--protocol PROTOCOL',
         'protocol(tcp,udp,sctp..)') { |o| options.proto = o }
  opt.on('-s', '--selector SELECTOR',
         'Selector for the association. 0 = Full Cert,'\
	 '1 = SubjectPublicKeyInfo') { |o| options.selector = o }
  opt.on('-u', '--usage USAGE',
         'Usage for the association.0 = PKIX-CA,'\
         '1 = PKIX-EE, 2 = DANE-TA, 3 = DANE-EE') { |o| options.usage = o }
  opt.on('-t', '--mtype MTYPE',
         'The Matching Type of the association.'\
         '0 = Exact Match, 1 = SHA-256, 2 = SHA-512') { |o| options.mtype = o }
  # this won't work with older ruby-versions
  options[:help] = opt.help
end.parse!

unless defined? options.certfile
  warn 'Usage-Error: No certificate was provided'
  exit 1
end

tlsa = Cryptorecord::Tlsa.new(options.to_h)
tlsa.read_file(options.certfile)
puts tlsa

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cryptorecord-1.0.0 exe/tlsarecord
cryptorecord-0.9.6 exe/tlsarecord
cryptorecord-0.9.2 exe/tlsarecord
cryptorecord-0.9.1 exe/tlsarecord