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.

43 lines
1.2KB

  1. require 'simpleidn'
  2. require 'cryptcheck'
  3. class HTTPSWorker
  4. include Sidekiq::Worker
  5. sidekiq_options retry: false
  6. def key_to_json(key)
  7. key.nil? ? nil : { type: key.type, size: key.size, rsa_size: key.rsa_equivalent_size }
  8. end
  9. def perform(host)
  10. idn = SimpleIDN.to_ascii host
  11. result = begin
  12. server = CryptCheck::Tls::Https::Server.new idn
  13. grade = CryptCheck::Tls::Https::Grade.new server
  14. {
  15. key: key_to_json(server.key),
  16. dh: server.dh.collect { |k| key_to_json k },
  17. protocols: server.supported_protocols,
  18. ciphers: server.supported_ciphers.collect { |c| { protocol: c.protocol, name: c.name, size: c.size, dh: key_to_json(c.dh) } },
  19. hsts: server.hsts,
  20. score: {
  21. rank: grade.grade,
  22. details: {
  23. score: grade.score,
  24. protocol: grade.protocol_score,
  25. key_exchange: grade.key_exchange_score,
  26. cipher_strengths: grade.cipher_strengths_score
  27. },
  28. error: grade.error,
  29. warning: grade.warning,
  30. success: grade.success
  31. }
  32. }
  33. rescue CryptCheck::Tls::Server::TLSNotAvailableException
  34. { no_tls: true }
  35. end
  36. Datastore.post :https, host, result
  37. end
  38. end