Create a gist now

Instantly share code, notes, and snippets.

Look into certificate bundle
#!/usr/bin/ruby
# ruby each-cert.rb 'openssl x509 -noout -text' input-file.crt
require 'open3'
class String
def certs
self.scan(/-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----/m)
end
end
cmd = ARGV.shift
ary = ARGF.read.certs
ary.each do |cert|
Open3.pipeline_w(cmd) do |i, ts|
i.print cert
i.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment