PHPMailer / DKIMValidator

PHP DKIM signature validator
Other
19 stars 13 forks source link

tag "c=" without "/..." == part with "/..." Optional part at rfc! #10

Open jetsam729 opened 3 years ago

jetsam729 commented 3 years ago
Warning: Undefined array key 1 Validator.php on line...
...
Fatal error: Uncaught TypeError: ...::canonicalizeBody(): Argument #2 ($style) must be of type string, null given, 

error at: line 87: [$headerCA, $bodyCA] = explode('/', $dkimTags['c']);

rfc4871-dkimbase.html#dkim-sig-hdr rfc6376#section-3.5 ..If only one algorithm is named, that algorithm is used for the header and "simple" is used for the body. For example, "c=relaxed" is treated the same as "c=relaxed/simple"...

maybe add before as: if(empty($dkimTags['c'])) $dkimTags['c'] = 'simple/simple'; if(!str_contains($dkimTags['c'],'/')) $dkimTags['c'] .='/simple';

example - email from phpclasses.org as "DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=phpclasses.org;..." AND - tag maybe not exists :) : rfc6376#section-3.5 : c= Message canonicalization (plain-text; OPTIONAL, default is "simple/simple").

LeonMelis commented 2 years ago

It would be much cleaner to use the union array operator, like this:

[$headerCA, $bodyCA] = explode('/', $dkimTags['c']) + ['simple', 'simple'];