In our last post, we provided an overview on the differences between transport layer and end-to-end encryption. We also provided some options for performing end-to-end email encryption, namely S/MIME and PGP/GPG.
In this post, we will provide step-by-step instructions for configuring S/MIME on OSX’s Mail.app as well as the ubiquitous iOS that powers your iPhone, iPad, etc.
S/MIME relies on the public PKI, so in order to use it we first need to request a certificate from a publicly trusted certificate authority. StartCom provides free (as in beer) certificates that can be used to vouch for the identity of a web server or individual for non commercial use. StartCom’s StartSSL is a small CA run by an awesome Israeli named Eddy Nigg. StartSSL has only been publicly compromised once, and we recommend supporting them by purchasing Verified or Enhanced Validation certificates for commercial use. However, the free certs are more than adequate to get a proof of concept deployment of end-to-end email encryption with S/MIME working.
StartSSL Certificate Enrollment
1) Open a browser and head on over to https://www.startssl.com. There’s a link in the upper left corner where you can sign up for an account.
2) Fill out the information in the subsequent form and continue through the enrollment process. You will receive a confirmation email at the address which you provided in the registration form.
3) Enter the code in your web browser that you received from StartSSL:
4) Next, you need to generate a Private Key which will be used to authenticate you with StartSSL in the future. Choose the “High Grade” Key (Default) and select “Continue.”
5) Once StartSSL finishes generating the key, it will prompt you to install the certificate into your browser. In the case of Mac, using Chrome, or Safari, this certificate will be installed into your keychain.
6) Click “Finish.” Congratulations, you now have a certificate to use with your mail account.
Note that you also received an email from StartSSL warning you about creating a backup of the certificate’s key. This should absolutely be done. If you lose the key, you will not be able to renew your S/MIME certificate in a year when it expires.
To back up your certificate (on OSX):
- Open the Keychain Access application.
- Select the “login” keychain.
- Select “Certificates” in the pane below.
- Locate the newly created certificate for the email address you just registered with. (Its name will be your email address.) You should be able to “expand” this certificate and verify a www.startssl.com private key that is also associated with it.
- Right click the certificate (not the private key) and choose “Export…”
- Select a file location where you want to save the exported certificate.
- Enter a strong (excellent) password to encrypt the key with.
- Place the file in a reliable location where it will be backed up.
Configuring Mail.app on OSX
1) Open the Mail application.
2) Go to “Preferences.”
3) Select the account you want to enable encryption for. Note that this should match the email address you provided in Step 2 of the StartSSL certificate enrollment process.
4) At the bottom in the TLS Certificate section, choose the certificate you just created with StartSSL.
That’s it! Now when you go to compose an email, you get two icons on the far right of the compose window. The closed padlock indicates that the message will be encrypted. The checkmark indicates that the message will be signed. Note that you cannot send encrypted emails to a recipient using S/MIME until they have sent you a signed message. When somebody sends you a signed message, Mail.app automatically imports their certificate (and public key) from the message, so that when you compose a message to them you will be able to toggle encryption by clicking the lock icon.
Any attacker who is sniffing the path between me and my recipient who is able to defeat the Opportunistic TLS, would see the message go across the wire as follows. Note that the subject of the encrypted message is sent in the clear, but the rest of the message (including any attachments) is encrypted and thus opaque to an eavesdropping attacker.
So, it’s complete jibberish to the evil attacker. However, to the legitimate recipient, whose public key my mail client has automatically encrypted the message to, the message looks just fine:
Note that the recipient is using Thunderbird, which natively supports S/MIME. The red button on the envelope indicates that the message is signed, and the lock icon indicates that the message is encrypted.
So there we have it, end-to-end encrypted email, configured quickly, and for free on your favorite mail client. But what about your mobile devices? Well, good news is that Apple introduced native support for S/MIME starting with iOS5. There are a couple of S/MIME capable email plug-ins available for Android also. Since iOS has native support, we’ll demonstrate configuring that first.
Configuring S/MIME on iOS (easiest way)
1) Mail yourself the backup .p12 file you made when you created your certificate.
2) Open the email on your iOS device, and then open the certificate file to import it on the device.
3) Click on “Settings,” then “Mail, Contacts, Calendars.”
4) Select the account to enable encryption for.
5) Choose to edit the Settings for the account.
6) Select “Advanced.”
7) Scroll down to the S/MIME section and toggle it on.
8) Enable “Sign” and select the certificate you just imported.
9) Enable “Encrypt” and select the certificate you just imported.
10) Now trash and permanently delete the certificate that you just imported.
If you would rather not send yourself your certificate and key via email, you can download and use the iPhone Configuration Utility to put the certificate and key on the phone via a USB connection.
Sending Encrypted Mail on iOS
In order to send encrypted mail to a recipient from your iOS device, first the recipient must send you a signed email. When you receive a signed email:
Click on the recipient’s name in the message to view the details.
Click on “View Certificate.”
And click “Install” to install the certificate into your iOS device’s cert repository. From this point on, when you compose a message to this recipient on your iOS device, it will automatically be signed and encrypted to their public key.
Voila! In just about 20 easy steps, we have achieved robust end-to-end encryption without any additional software. As we mentioned in our end-to-end primer, there are various ways to achieve end-to-end encryption. We will be covering PGP/GPG based end-to-end email encryption in a subsequent post.
To learn more about what SendGrid is doing to ensure email security, read our announcement about our implementation of opportunistic encryption using TLS.