summaryrefslogtreecommitdiff
path: root/bin-src/crtsh-getcerts
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-03-14 18:18:31 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-03-17 13:49:41 -0400
commitb54a1c9686eec3c1114e9b58cb67679ba59c45bd (patch)
tree0bdb2f3ed51ff077a8c3e337e4bc556aacec108e /bin-src/crtsh-getcerts
parent54feeb027d6e5a760b49769dfe695ea2591dc6fe (diff)
directories
Diffstat (limited to 'bin-src/crtsh-getcerts')
-rwxr-xr-xbin-src/crtsh-getcerts28
1 files changed, 28 insertions, 0 deletions
diff --git a/bin-src/crtsh-getcerts b/bin-src/crtsh-getcerts
new file mode 100755
index 0000000..0191e2e
--- /dev/null
+++ b/bin-src/crtsh-getcerts
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+require 'nokogiri'
+require 'open-uri'
+
+certs = {}
+ARGV.each do |domain|
+ [ domain, "%.#{domain}" ].each do |pattern|
+ Nokogiri::XML(open("https://crt.sh/atom?identity=#{pattern}&exclude=expired")).css('feed > entry').each do |entry|
+ url = entry.css('id').first.text.split("#").first
+
+ updated = entry.css('updated').first.text
+
+ html = Nokogiri::HTML(entry.css('summary').first.text)
+ html.css('br').each{|br| br.replace("\n")}
+ pem = html.css('div').first.text
+
+ lines = pem.split("\n")
+ lines.insert(1, "X-Crt-Sh-Url: #{url}", "X-Crt-Sh-Updated: #{updated}")
+ pem = lines.join("\n")+"\n"
+
+ certs[url] = pem
+ end
+ end
+end
+
+certs.each do |url, pem|
+ print pem
+end