attributes.rb 853 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module SecureMailing::SMIME::Certificate::Attributes
  3. def extensions_as_hash
  4. extensions.each_with_object({}) do |ext, hash|
  5. hash[ext.oid] = ext.value.split(',').map(&:strip)
  6. end
  7. end
  8. def fetch_email_addresses
  9. subject_alt_name = extensions_as_hash['subjectAltName']
  10. return [] if subject_alt_name.blank?
  11. subject_alt_name.each_with_object([]) do |entry, result|
  12. identifier, email_address = entry.split(':').map(&:downcase)
  13. next if identifier.exclude?('email') && identifier.exclude?('rfc822')
  14. next if !EmailAddressValidation.new(email_address).valid?
  15. result.push(email_address)
  16. end
  17. end
  18. def determine_uid
  19. return public_key.n.to_s(16) if rsa?
  20. OpenSSL::Digest.new('SHA1', public_key.to_der).to_s
  21. end
  22. end