addSignature() public method

Add the signature to the given Headers.
public addSignature ( Swift_Mime_HeaderSet $headers ) : Swift_Signers_DKIMSigner
$headers Swift_Mime_HeaderSet
return Swift_Signers_DKIMSigner
Example #1
0
 public function addSignature(Swift_Mime_HeaderSet $headers)
 {
     if (!$this->_peclLoaded) {
         return parent::addSignature($headers);
     } else {
         dkim_eom($this->_dkimHandler);
         $headers->addTextHeader('DKIM-Signature: ', dkim_getsighdr($this->_dkimHandler));
     }
     return $this;
 }
Example #2
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=; i=@dummy.nxdomain.be; s=dummySelector; c=simple/relaxed; t=1299879181; b=M5eomH/zamyzix9kOes+6YLzQZxuJdBP4x3nP9zF2N26eMLG2/cBKbnNyqiOTDhJdYfWPbLIa 1CWnjST0j5p4CpeOkGYuiE+M4TWEZwhRmRWootlPO3Ii6XpbBJKFk1o9zviS7OmXblUUE4aqb yRSIMDhtLdCK5GlaCneFLN7RQ=');
 }