1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/openssl/sample/cert2text.rb
nahi ccdc8d302a * ext/openssl/sample: Add samples.
- cert2text.rb: Dump certificate file as text.
  - crlstore.rb: CRL store implementation.  Fetch CRL via HTTP when
    http-access2 is installed.
  - certstore.rb: Certificate store implementation.
  - cert_store_view.rb: Certificate store viewer with FXRuby.  Uses
    c_rehash.rb, crlstore.rb and certstore.rb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-25 15:12:26 +00:00

23 lines
376 B
Ruby

#!/usr/bin/env ruby
require 'openssl'
include OpenSSL::X509
def cert2text(cert_str)
[Certificate, CRL, Request].each do |klass|
begin
puts klass.new(cert_str).to_text
return
rescue
end
end
raise ArgumentError.new('Unknown format.')
end
if ARGV.empty?
cert2text(STDIN.read)
else
ARGV.each do |file|
cert2text(File.read(file))
end
end