ZSmime enables Zope to generate S/MIME-signed and -encrypted messages.
This is useful where Zope accepts confidential information over the web, e.g., credit card numbers, Swiss bank account instructions, etc. Such information can be protected by ZSmime and relayed off-site immediately. This reduces the value of the information carried on-site and in turn reduces the impact of a successful attack against the site.
Even if the S/MIME-protected information remains on-site, it is now encrypted - this introduces additional cost in defeating the protection and may mitigate the effect of a successful site penetration.
S/MIME - Secure Multipurpose Internet Mail Extensions [RFC 2311, RFC 2312] - provides a consistent way to send and receive secure MIME data. Based on the popular Internet MIME standard, S/MIME provides the following cryptographic security services for electronic messaging applications - authentication, message integrity and non-repudiation of origin (using digital signatures) and privacy and data security (using encryption).
To create an S/MIME-signed message, ZSmime needs an RSA key pair (this consists of a public key and a private key) and an X.509 certificate of said public key.
To create an S/MIME-encrypted message, ZSmime needs the recipients' certificates.
To create an S/MIME-signed and -encrypted message, ZSmime first signs the data to create a signed message, then encrypts the signed message with the public keys of the recipients.
You may generate key pairs and obtain certificates by using a commercial certification authority service such as Verisign.
You can also do so using freely-available software. For the purpose of automated S/MIME message-generation by Zope, this approach is cheap and effective.
We now work through the process using OpenSSL. This assumes you have OpenSSL installed properly on your system.
orderbot@example.dom.
openssl req -newkey rsa:1024 -nodes -x509 -days 365 -out zsmime_sender.pem
This command generates a 1024-bit RSA key pair, unencrypted, into the file
privkey.pem; it also generates a self-signed X.509 certificate
for the public key into the file zsmime_sender.pem. The
certificate is valid for 365 days.
To check the content of zsmime_sender.pem, execute the following:
openssl x509 -noout -text -in zsmime_sender.pem
privkey.pem to zsmime_sender.pem:
(Cat-less users please improvise.)
cat privkey.pem >> zsmime_sender.pem
privkey.pem will be overwritten with the
new key pair.
openssl req -newkey rsa:1024 -nodes -x509 -days 365 -out zsmime_recip.pem
enter.
openssl pkcs12 -export -in zsmime_recip.pem -inkey privkey.pem
-name "ZSmime" -out zsmime_recip.p12
GuardedFile is a Zope product that eases the creation of protected Zope File objects called, unsurprisingly, GuardedFiles. A GuardedFile is a Zope File that is accessible by proxy only.
You can configure a Zope File to be like a GuardedFile through Zope's management interface. The GuardedFile product simply makes the process much more convenient.
zsmime_sender.pem
as a GuardedFile. Give it a Zope id signer.
zsmime_recip.pem
as a GuardedFile. Give it a Zope id recip.
<pre> <dtml-smime signer="signer" recipients="recip"> The quick brown <dtml-var id> fox. </dtml-smime> </pre>
<dtml-sendmail smtphost="smtp.example.dom"> From: "The Order Bot" <orderbot@example.dom> To: "The Back Office" <backoffice@example.dom> Subject: Another sucker bought our hype. <dtml-smime signer="signer" recipients="recip"> Widget Id: XXX-YYY-111-999 Credit Card: 1234-5678-9012-3456 (yada yada yada) </dtml-smime> </dtml-sendmail>
The Order Bot to The Back Office
regarding Another sucker.
Suppose The Back Office reads mail using Netscape
Messenger. Here's how to import the signer's certificate and the recipient
certificate and key into Messenger, in order to read S/MIME messages from
The Order Bot:
zsmime_recip.p12
from the ensuing file selection dialog box.
zsmime_sender.pem as a CA
certificate, so that Messenger will mark as "trusted" messages signed by
zsmime_sender.pem's key. To do this, first create a
DER encoding of zsmime_sender.pem:
openssl x509 -inform pem -outform der -in zsmime_sender.pem -out zsmime_sender.der
zsmime_sender.der into Navigator as a file
of MIME type application/x-x509-ca-cert. You'll need to do this by
clicking on zsmime_sender.der from a HTTP server, with the
correct MIME type mapping. Follow the series of dialog boxes to accept
zsmime_sender.der as a CA for certifying email users.
The Back Office is now able to decrypt and
read The Order Bot's messages with Messenger.
Messenger will indicate that each message is "encrypted and
signed" via the "stamp" icon on the message window's top
right corner.
Clicking on the "stamp" icon will bring you to the Security Info dialog
box. Messenger informs you that the message is encrypted with 168-bit
DES-EDE3-CBC and that it is digitally signed by the public key contained
in the certificate zsmime_sender.pem.
I do not know how to do this since I do not use Outlook. Information on this, as well as on other S/MIME tools, is gratefully accepted.
ZSmime is designed to run autonomously; as such, the signer key cannot be passphrase-protected, since there may not be a human operator available to supply the passphrase. This means anyone who has access to the signer key can generate signatures with it.
(This practice causes debate in the security community periodically. Some argue that your operational procedure should be such that a person is always required (and available!) to supply passphrases and other necessary information. Ultimately, your security posture depends on the value of your web site and its threat model.)
The signer key should be single-purpose, i.e., its only use should be for your Zope application to generate S/MIME messages. It should also be reasonably well-handled from creation to installation on the Zope site. Within Zope, it is protected by Zope's permissions settings; as such, it should be installed as a GuardedFile.
ZSmime uses the signer key to provide message integrity and non-repudiation of origin.
It is possible to operate ZSmime with just recipient certificates; however, this means S/MIME messages you receive that are encrypted to those recipient certificates may not necessarily originate from your Zope site. (This mode of operation is not enabled.)
The recipient certificates should also be uploaded into Zope as GuardedFiles. This prevents an adversary from grabbing those certificates off your site and flooding you with S/MIME-encrypted mail.
You should upload the key and certificates over HTTPS.
ZSmime uses three-key triple-DES, as supported by "strong cryptography" versions of Netscape Messenger and Microsoft Outlook.
You can change the cryptographic algorithm to 40-bit RC2, as supported by "weak cryptography" versions of Messenger and Outlook, by modifying ZSmime's source code. This is not recommended.
ZSmime is published under the Zope Public Licence (ZPL). All rights reserved. Usual disclaimers apply.
Thanks to: