Swift_Signers_DKIMSigner::setBodyCanon PHP Method

setBodyCanon() public method

Set the body canonicalization algorithm.
public setBodyCanon ( string $canon ) : Swift_Signers_DKIMSigner
$canon string
return Swift_Signers_DKIMSigner
    public function setBodyCanon($canon)
    {
        if ($canon == 'relaxed') {
            $this->bodyCanon = 'relaxed';
        } else {
            $this->bodyCanon = 'simple';
        }
        return $this;
    }

Usage Example

Example #1
0
 public function testSigningSimpleRelaxed256()
 {
     $headerSet = $this->_createHeaderSet();
     $messageContent = "Hello World";
     $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))) . '/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector');
     $signer->setHashAlgorithm('rsa-sha256');
     $signer->setSignatureTimestamp('1299879181');
     $signer->setBodyCanon('relaxed');
     $altered = $signer->getAlteredHeaders();
     $this->assertEquals(array('DKIM-Signature'), $altered);
     $signer->reset();
     $signer->setHeaders($headerSet);
     $this->assertFalse($headerSet->has('DKIM-Signature'));
     $signer->startBody();
     $signer->write($messageContent);
     $signer->endBody();
     $signer->addSignature($headerSet);
     $this->assertTrue($headerSet->has('DKIM-Signature'));
     $dkim = $headerSet->getAll('DKIM-Signature');
     $sig = reset($dkim);
     $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha256; bh=f+W+hu8dIhf2VAni89o8lF6WKTXi7nViA4RrMdpD5/U=; d=dummy.nxdomain.be; h=; [email protected]; s=dummySelector; c=simple/relaxed; t=1299879181; b=M5eomH/zamyzix9kOes+6YLzQZxuJdBP4x3nP9zF2N26eMLG2/cBKbnNyqiOTDhJdYfWPbLIa 1CWnjST0j5p4CpeOkGYuiE+M4TWEZwhRmRWootlPO3Ii6XpbBJKFk1o9zviS7OmXblUUE4aqb yRSIMDhtLdCK5GlaCneFLN7RQ=');
 }
All Usage Examples Of Swift_Signers_DKIMSigner::setBodyCanon