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.

check_worker.rb 1.3KB

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