Class: MailAuth::Arc::MessageSignature

Inherits:
Object
  • Object
show all
Defined in:
lib/mailauth/arc/message_signature.rb

Overview

An ARC-Message-Signature (RFC 8617 §4.1.2): a DKIM signature over the message in all but name, differing in carrying no version tag, in taking i= as the instance rather than an identity, and in leaving From free — what it covers is the hop's business, not ours.

Constant Summary collapse

REQUIRED_TAGS =
%w[ a b bh d h s ].freeze
DEFAULT_CANONICALIZATION =

§4.1.2 gives the AMS DKIM's syntax and semantics bar three named differences, none of them canonicalization, which would leave an absent c= meaning simple/simple (RFC 6376 §3.5). Signers read it the other way and the conformance suite requires relaxed, so relaxed it is: simple canonicalization survives no intermediary, which is the one thing every message carrying this header has crossed.

"relaxed/relaxed".freeze

Instance Method Summary collapse

Constructor Details

#initialize(message, field, tags, resolver:) ⇒ MessageSignature

Returns a new instance of MessageSignature.



20
21
22
# File 'lib/mailauth/arc/message_signature.rb', line 20

def initialize(message, field, tags, resolver:)
  @message, @field, @tags, @resolver = message, field, tags, resolver
end

Instance Method Details

#resultObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mailauth/arc/message_signature.rb', line 24

def result
  validate

  if body_hash_matches?
    verified? ? signature(Status::PASS) : failed("bad signature")
  else
    failed("body hash did not verify")
  end
rescue Dkim::Malformed => error
  signature Status::PERMERROR, comment: error.message
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