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.

35 lines
726B

  1. require 'erb'
  2. require 'parallel'
  3. module CryptCheck
  4. module Tls
  5. def self.analyze(host, port)
  6. ::CryptCheck.analyze host, port, TcpServer, Grade
  7. end
  8. def self.colorize(cipher)
  9. colors = case
  10. when /^SSL/ =~ cipher
  11. :critical
  12. when :TLSv1_2 == cipher
  13. :good
  14. end
  15. cipher.to_s.colorize colors
  16. end
  17. def self.key_to_s(key)
  18. size, color = case key.type
  19. when :ecc
  20. ["#{key.group.curve_name} #{key.size}", :good]
  21. when :rsa
  22. [key.size, nil]
  23. when :dsa
  24. [key.size, :critical]
  25. when :dh
  26. [key.size, :warning]
  27. end
  28. "#{key.type.to_s.upcase.colorize color} #{size.to_s.colorize key.status} bits"
  29. end
  30. end
  31. end