Class: MailAuth::Dkim::Signer
- Inherits:
-
Object
- Object
- MailAuth::Dkim::Signer
- Defined in:
- lib/mailauth/dkim/signer.rb
Overview
Signs a message per RFC 6376 §5, relaxed/relaxed.
Constant Summary collapse
- DEFAULT_SIGNED_HEADERS =
The RFC 6376 §5.4.1 example set: what a reader's client renders or threads on.
%w[ from sender reply-to subject date message-id to cc mime-version content-type content-transfer-encoding in-reply-to references list-id list-help list-owner list-unsubscribe list-unsubscribe-post list-subscribe list-post ].freeze
- OVERSIGNED_HEADERS =
Named in h= once more than they occur — a name past its count matches nothing (§5.4.2), so an instance added after signing breaks the signature.
%w[ from to cc subject date reply-to message-id ].freeze
Instance Method Summary collapse
- #field ⇒ Object
-
#initialize(raw, domain:, selector:, key:, headers: nil, oversign: OVERSIGNED_HEADERS, expires_in: nil, now: Time.now) ⇒ Signer
constructor
A new instance of Signer.
- #signed_message ⇒ Object
Constructor Details
#initialize(raw, domain:, selector:, key:, headers: nil, oversign: OVERSIGNED_HEADERS, expires_in: nil, now: Time.now) ⇒ Signer
Returns a new instance of Signer.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mailauth/dkim/signer.rb', line 22 def initialize(raw, domain:, selector:, key:, headers: nil, oversign: OVERSIGNED_HEADERS, expires_in: nil, now: Time.now) @message = Message.new(raw) @domain = Domain.normalize(domain) @selector = Domain.normalize(selector) @key = key @requested = (headers || DEFAULT_SIGNED_HEADERS).map(&:downcase) @oversign = oversign.map(&:downcase) @expires_in = expires_in @now = now end |
Instance Method Details
#field ⇒ Object
37 38 39 40 41 42 |
# File 'lib/mailauth/dkim/signer.rb', line 37 def field @field ||= begin validate unsigned_field + [ signature ].pack("m0").scan(/.{1,72}/).join("\r\n\t") + CRLF end end |
#signed_message ⇒ Object
33 34 35 |
# File 'lib/mailauth/dkim/signer.rb', line 33 def field + @message.raw end |