-
-
Save skeptomai/9789705 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'openssl' | |
pathglob = File.join(ARGV[0], "*.crt") | |
sans = [] | |
Dir.glob(pathglob).each do |cert_filename| | |
cert = OpenSSL::X509::Certificate.new File.read(cert_filename) | |
cert.extensions.each do |ext| | |
next if ext.oid != "subjectAltName" | |
ostr = OpenSSL::ASN1.decode(ext.to_der).value.last | |
sequence = OpenSSL::ASN1.decode(ostr.value) | |
sequence.value.each{|san| | |
case san.tag | |
when 2 # dNSName in GeneralName (RFC5280) | |
sans << san.value | |
end | |
} | |
end | |
end | |
puts sans.join("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment