Page 1 of 1
message signing
Posted: Mon May 21, 2007 3:18 am
by tkejzlar
Hi,
I am using swift for sending e-mails from our accounting system and we now need to sign outgoing messages (we have been doing this in the past using openssl_pkcs7-sign PHP function) - can we somehow sign outgoing messages when sending them via swiftmailer?
Thanks, Tom.
Posted: Mon May 21, 2007 3:39 am
by Chris Corbyn
I'm not sure how message signing works, but you are going to do you'd write a BeforeSendListener plugin to grab the message before it's sent then sign it. I can probably write an extension to Swift_Message too... something like Swift_SignedMessage. I'll look into how it works, or if you want to brief me on it that would be good

Posted: Tue May 22, 2007 2:02 am
by tkejzlar
Well, I myself am not an expert on message signing, the code we've been using was written by someone who does not work in our company anymore. But, as I understand it, openssl_pkcs7_sign PHP function is used for message signing, and it should work like this:
Code: Select all
$text = 'test e-mail body';
$file = file_put_contents('signing.txt', $text);
openssl_pkcs7_sign('signing.txt',
'signed.txt',
'file://openssl/certifikat2006az7.pem',
'file://openssl/private_key2006az7.pem',
array());
$data = file_get_contents('signed.txt');
$parts = explode("\n\n", $data, 2);
$parts[0] .= "\nFrom: test <tomas.kejzlar@gmail.com>\n";
mail('somebody@somewhere', 'test', $parts[1], $parts[0]);
Posted: Tue May 22, 2007 5:07 am
by Chris Corbyn
Thanks, it looks pretty easy. I'll check whatever RFC applies to it too
I should be able to release a plugin which does what you're doing.
Posted: Thu May 24, 2007 8:47 am
by tkejzlar
d11wtq wrote:I should be able to release a plugin which does what you're doing.
That would be very nice. I've tried to do it but I've ended up with attachet "smime.p7s" file which - under Thunderbird - is treated as an unattached message signature...
Thanks, Tom.
Posted: Thu May 24, 2007 9:54 am
by Chris Corbyn
Apologies for the slow progress on this. I haven't actually had a chance to work on anything yet as we've had guests living with us for the past 4 weeks but they flew back to Australia this morning so I can hopefully find time to work on this tonight

Posted: Thu May 24, 2007 12:08 pm
by tkejzlar
Do not apologize... It would be perfect if you could look at it tonight, but it is not critical and we can probbably solve sending signed messages temporarily some other way...
Posted: Tue Jun 05, 2007 2:12 pm
by tkejzlar
Hi, may I just ask whether you have made any progression on message signing? (just being curious...)
Tom.
Posted: Tue Jun 05, 2007 5:43 pm
by Chris Corbyn

Sorry, I actually totally forgot about this after trying to fathom out what I was doing wrong with openssl_pkcs7_sign().
Unless you consider my confuddled few lines of experimentation a start, I'm basically where I was last time I posted
Code: Select all
$message = new Swift_Message("My subject");
$message->setBody("my message");
/*$part1 = new Swift_Message_Part("some part");
$message->attach($part1);
$part2 = new Swift_Message_Part("another_aprt", "text/html");
$message->attach($part2);*/
$message->setTo(array(new Swift_Address("cac@parrswood.manchester.sch.uk"), new Swift_Address("chris@iris.ac")));
$message->setFrom("chris@w3style.co.uk");
$stream = $message->buildData();
$fp = fopen("signed/unsigned.txt", "w");
fwrite($fp, $stream->readFull());
fclose($fp);
echo file_get_contents("signed/unsigned.txt");
echo "===================================";
openssl_pkcs7_sign("signed/unsigned.txt", "signed/signed.txt", "file://mycert.pem", array("file://mykey.pem", "swiftmailer"), array("From: <chris@w3style.co.uk"), OPENSSL_KEYTYPE_RSA);
echo file_get_contents("signed/signed.txt");
This just gave me errors about not being able to create the email structure and I got distracted with something else.
Sorry about that.
Thanks for the reminder. I should add it to the TODO file really.
Re: message signing
Posted: Fri Apr 18, 2008 9:10 am
by lukasus
Hi, I try to find any possibility to sign S/MIME e-mails via PHP, but I found nothing. Do you know any ideas?
Re: message signing
Posted: Fri Apr 18, 2008 10:14 am
by Chris Corbyn
It's going to be in the enterprise edition of Swift Mailer version 4. The enterprise edition will be a paid download however.
Re: message signing
Posted: Sun Apr 20, 2008 2:58 pm
by lukasus
Ok, I would buy it, when it will be?
Re: message signing
Posted: Sun Apr 20, 2008 5:15 pm
by Chris Corbyn
The short answer is "I don't have an accurate ETA", but you may wish to subscribe to this thread:
viewtopic.php?f=52&t=81467