Use official SSLLabs API to fetch user-agent support

v1
Aeris 7 years ago
parent 66fc57c4d8
commit 9c93fbf5e2
  1. 33
      bin/fetch_ssllabs_useragent
  2. 19
      bin/fetch_ssllabs_useragents
  3. 6958
      config/user-agents-ciphers.json

@ -1,33 +0,0 @@
#!/usr/bin/env ruby
require 'httparty'
require 'nokogiri'
require 'nokogiri-pretty'
require 'open-uri'
uas = Nokogiri::HTML open 'https://www.ssllabs.com/ssltest/clients.html'
uas = Hash[uas.css('#multiTable > tr > td:first > a').collect do |ua|
ua_url = ua.attr :href
ua = Nokogiri::HTML open "https://www.ssllabs.com/ssltest/#{ua_url}"
name = ua.at_css('h1').text.sub('User Agent Capabilities:', '').strip
puts name
reports = ua.css '.reportTable'
protocols = Hash[reports[0].css('tr').collect do |protocol|
protocol, support = protocol.css 'td'
next if protocol.attr(:class) == 'tableHead'
protocol = protocol.text.sub("\xC2\xA0 INSECURE", '').strip
support = support.text == 'Yes'
[protocol, support]
end.reject &:nil?]
ciphers = Hash[reports[1].css('tr').collect do |cipher|
cipher, size = cipher.css 'td'
next if cipher.attr(:class) == 'tableHead' or size.nil?
cipher = /(.*) \(0x(.*)\).*/.match cipher.text
cipher = ["0x#{cipher[2].upcase.rjust(2, '0')}", cipher[1]]
end.reject &:nil?]
[name, { protocols: protocols, ciphers: ciphers }]
end]
File.write 'config/user-agent.json', JSON.pretty_generate(uas, {indent: "\t"})

@ -0,0 +1,19 @@
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
PROTOCOLS = {
768 => 'SSL 3',
769 => 'TLS 1.0',
770 => 'TLS 1.1',
771 => 'TLS 1.2'
}
uas = JSON.load open 'https://api.dev.ssllabs.com/api/v3/getClients'
uas = uas.collect do |ua|
name = [ua['name'], ua['version'], ua['platform']].compact.join ' '
protocols = ua['lowestProtocol'].upto(ua['highestProtocol']).collect { |n| PROTOCOLS[n] }
ciphers = ua['suiteIds'].zip(ua['suiteNames']).collect { |i, n| ["0x#{i.to_s(16).upcase.rjust(2, '0')}", n]}.to_h
[name, { protocols: protocols, ciphers: ciphers }]
end
File.write 'config/user-agents-ciphers.json', JSON.pretty_generate(uas, {indent: "\t"})

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save