You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cryptcheck-rails/bin/fetch_ssllabs_useragents

20 lines
659 B

#!/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"})