Class: MailAuth::Dkim::Verification
- Inherits:
-
Object
- Object
- MailAuth::Dkim::Verification
- Defined in:
- lib/mailauth/dkim.rb
Overview
One DKIM-Signature header, taken from its tags to a verdict.
Instance Method Summary collapse
-
#initialize(message, field, resolver:, now:) ⇒ Verification
constructor
A new instance of Verification.
- #result ⇒ Object
Constructor Details
#initialize(message, field, resolver:, now:) ⇒ Verification
Returns a new instance of Verification.
88 89 90 91 92 93 |
# File 'lib/mailauth/dkim.rb', line 88 def initialize(, field, resolver:, now:) @message, @field, @resolver, @now = , field, resolver, now = Dkim.(field.split(":", 2).last.to_s) @well_formed = !.nil? @tags = || {} end |
Instance Method Details
#result ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/mailauth/dkim.rb', line 95 def result validate if expired? failed("signature expired") elsif postdated? failed("signature timestamp in the future") elsif body_hash_matches? verified? ? signature(Status::PASS) : failed("bad signature") else # Some verifiers call this neutral. We call it failure: the signer # said what the body would hash to, and it hashes to something else. failed("body hash did not verify") end rescue Malformed => error signature(Status::PERMERROR, comment: error.) rescue Resolver::NotFound signature(Status::PERMERROR, comment: "no key for #{key_name}") rescue Resolver::Timeout, Resolver::ServerFailure signature(Status::TEMPERROR, comment: "DNS failure resolving #{key_name}") end |