« Mythical standards | Main | Selling music by subscription vs. human nature. »

February 2, 2005

Encryption: Create your own key in private, then get a Thawte cert!

Another adventure in the world of digital cryptography.

Last weekend, while over in Berlin, I managed to get two friendly Thawte notaries to take a look at my passport and then get Thawte to sign my digital key used to digitally sign e-mail. They verified that I am the person that I claim to be, so somebody else can trust my digital signature. The notarization process is a nice thing, not only because it established trust by always having at least two notaries verify your identify, but also because you get to meet some random geeks in town!

As usual, I encountered some oddities. In the following, I'll describe my solutions to two problems. The first is a security issue: Any certification authority such as Thawte may have the chance to see and store your private key, which is not a good thing. This can happen in the web-browser supported process of generating keys. The second issue is a technical problem that occurs only in Mac OS X: the Mac's keychain doesn't like to import several certificates for the same key pair. In the following, I assume you have a basic understanding of how public key infrastructure with X.509 certificates (for S/MIME e-mail encryption) works. You can read up on it in an earlier blog entry.

Once you have enough trust-points, you will need to get a new certificate from Thawte. The first certificate they give you has no name it, because they couldn't verify your name. The new one
demonstrates that they believe your name to be authentic, not just your e-mail address.

However, the way Thawte is set up, it seems to generate a new secret/public key pair for a new
certificate. That is annoying, because you'll get encrypted e-mail from people that don't have your new public key yet - and you can't decrypt it. The other problem is that Thawte has the possibility of retaining your secret key, which is a big no-no, of course, as they - or some intelligence agency - could read your e-mail. Let's not be paranoid: Thawte is a company from South Africa, so it's not a US company within easy reach of CIA and NSA. But either way you want to guard your secret key closely, and keep it on your machine at all times.

I found this tutorial by Daniel Baker, who thankfully figured out how to generate a public/secret key pair locally with the openssl command, without going through Thawte's key generation process. Then, the public key is sent to Thawte using their special developer's option, and they sign it for you. It is sent back, needs to be post-processed a little and can then be imported into your own system. Daniel describes the process for Mac OS X, but it should work with little modification for Linux, and in principle on Windows, too.

There is one caveat I noticed on OS X 10.3. You may want to request multiple certificates using the same key pair: one for each e-mail address. (I use the same public/private key to reduce clutter.) However, when you import the certificates into your OS X keychain, it will complain that "the item already exists in your keychain". It will refuse to import any certificates but the first one. The reason for that seems to be that the final certificate file always contains a copy of the secret key that is being certified, and OS X detects that this key is already present in the key chain. Unfortunately, it abandons the whole import!

The solution to this is to bundle all certificates for import, as follows. Suppose you have three e-mail addresses and request one certificate for each. Download your certificates with Thawte and modify the files with a text editor as described in Daniel's tutorial. I assume you name them in thawte-cert-email-A.txt through -C.txt. The next step is to convert the certificates with the following command - however, output all of the results into the same file:

openssl pkcs7 -print_certs -in thawte-cert-email-A.txt >deliver.certs
openssl pkcs7 -print_certs -in thawte-cert-email-B.txt >>deliver.certs
openssl pkcs7 -print_certs -in thawte-cert-email-C.txt >>deliver.certs

Then, convert the resulting certificate to pkcs12 binary format for the key chain:

openssl pkcs12 -export -inkey mail.key -in deliver.certs -out mail.p12

I assume, the file mail.p12 now contains your key pair, Thawte's root certificate and a certificate for each e-mail address.
You should now use Keychain Access (find it in /Applications/Utilities/) to move your 'secret key' to an extra key chain. I recommend keeping it there, because you might get e-mail encrypted to your old key which you will want to decrypt at some point. Look for an entry of type 'private key'. Here's what that should look like:

keychain access screenshot

Create a new key chain, give it meaningful name - such as 'old keys' - and drag&drop the private key there. It's a good idea to move your public key and the old certificate - if you have one - for this key pair too.

You can then import it into the keychain by saying open mail.p12

Keychain Access will ask you, where to import it, and not complain about importing something that already exists. That's it!

A final tip: I recommend you back up your key pair (file mail.key) and the certificate file mail.p12 in a safe place.

Posted by dr at February 2, 2005 11:14 AM


Trackback Pings

Please use the following TrackBack URL:
http://www.davids-world.com/~dr/cgi-bin/mt/mt-tb.cgi/25

Comments

The Thawte system is actually not as lame as you're thinking. On X86-based browsers (yes, even in Linux) key generation is handled locally and not on the Thawte server. They never have access to the private component of the generated key, which is why there exist all the dire warnings about having to download the certificate from the same machine and browser that made the request.

For non-X86 machines (like Mac OS X) this is not the case and you are right -- Thawte does generate the keypair on the local side.

Your point about retaining the same actual key from cert to cert is valid, though, and a great reason to use the manual technique even on X86 machines.

Posted by: Nugget at February 2, 2005 4:48 PM

thanks for your comment... I noticed that they're generating something locally (on my machine) when I use Mozilla. However, it's absolutely not a transparent process: I don't know what's happening where, and I can't control it.

I mean: of course I'm being paranoid - but if we're talking security, we'd better not leave obvious loop-holes. Even if Thawte doesn't retain anything, the key is sent over an SSL connection, sometimes they have a 40-bit session key. I guess that's crackable, if you have a cluster and a good reason to do so, e.g. if you're some Chinese government agency, you have centralized logging mechanisms and you'd like to catch a Chinese "dissident"...

Posted by: David Reitter [TypeKey Profile Page] at February 2, 2005 10:30 PM

Post a comment




Remember Me?

(you may use HTML tags for style)