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 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 { |d, _| results[d].sort! { |a, b| score(a) <=> score(b) } }
  47. puts 'Generate results'
  48. File.write 'output/index.html', ERB.new(File.read('index.erb')).result(binding)