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.

sslcheck-ssllabs 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env ruby
  2. require 'erb'
  3. require 'yaml'
  4. $:.unshift 'lib'
  5. require 'sslcheck'
  6. SCORES = %w(A+ A A- B C D E F T M)
  7. def score(a); SCORES.index a.rank; end
  8. def check(hostname)
  9. hostname.strip!
  10. print ' ', hostname, ' : '
  11. begin
  12. result = SSLCheck::SSLLabs::API.new hostname
  13. puts result.rank
  14. result
  15. rescue SSLCheck::SSLLabs::NoEncryptionError
  16. puts 'no encryption'
  17. raise
  18. rescue => e
  19. puts e
  20. raise
  21. end
  22. end
  23. config = YAML.load_file 'hosts.yml'
  24. results = Hash[config.collect { |c| [c['description'], []] }]
  25. loop do
  26. waiting = false
  27. config.each do |c|
  28. description, hosts = c['description'], c['hostnames']
  29. puts description
  30. hosts.clone.each do |host|
  31. begin
  32. results[description] << check(host)
  33. hosts.delete host
  34. rescue SSLCheck::SSLLabs::WaitingError
  35. waiting = true
  36. rescue SSLCheck::SSLLabs::Error
  37. rescue => e
  38. p e.backtrace
  39. end
  40. end
  41. end
  42. break if not waiting
  43. puts 'Waiting end of analyze'
  44. sleep 1*60
  45. end
  46. results.each do |d, _|
  47. results[d].sort! do |a, b|
  48. cmp = score(a) <=> score(b)
  49. cmp != 0 ? cmp : a.hostname <=> b.hostname
  50. end
  51. end
  52. puts 'Generate results'
  53. File.write 'output/index.html', ERB.new(File.read('index.erb')).result(binding)