public function signMessage(Swift_Message $message)
{
if (null === $this->signCertificate && null === $this->encryptCert) {
return $this;
}
// Store the message using ByteStream to a file{1}
// Remove all Children
// Sign file{1}, parse the new MIME headers and set them on the primary MimeEntity
// Set the singed-body as the new body (without boundary)
$messageStream = new Swift_ByteStream_TemporaryFileByteStream();
$this->toSMimeByteStream($messageStream, $message);
$message->setEncoder(Swift_DependencyContainer::getInstance()->lookup('mime.rawcontentencoder'));
$message->setChildren(array());
$this->streamToMime($messageStream, $message);
}