Exchange Server 2007 – troubleshooting SSL

Some points to troubleshoot an Exchange Server 2007 SSL configuration. For god knows what reason, Microsoft decided that everything needed to be command line, so it’s pretty easy to get stuck.

Starting point – find what certificates are installed

Run the following cmdlet from the Exchange Shell:


You should see output similar to:

Thumbprint                Services Subject
----------                -------- -------
1B5667CCB803BC4AD13E7E51A .IP.W
103F3F32814A48D2416ECC5DB S....    CN=exch-07
43C6A1548782A25ABA425B471 ....W    CN=exch-07.example....

The Thumbprint is the identifier used in other cmdlets when referring to a specific certificate. The Services are what the certificate is enabled for; each letter indicates what service(s) are configured:

Letter Service
S SMTP – outbound e-mail secured with TLS
I IMAP – inbound e-mail
P POP3 – inbound e-mail
U Unified Messaging – I believe this is for Outlook Anywhere
W Outlook Web Access / IIS – webmail

You can also get more detailed information about a specific certificate with the following command:

Get-ExchangeCertificate [thumbprint] | fl

Are the certificates enabled for the right things? Are multiple certificates enabled for the same service (as per the example above)? Is the right certificate installed at all? Has the certificate expired? Does the certificate have incorrect or misspelt details in the DN? Etc..

Handy commands:

Turn a specific service on (Outlook Web Access in this example):

Enable-ExchangeCertificate -Thumbprint [thumbprint] -Services IIS

Disable a certificate:

Enable-ExchangeCertificate -Thumbprint [thumbprint] -Services None

Remove a certificate:
This command does what it says on the tin – there is no undo!

Remove-ExchangeCertificate -Thumbprint [thumbprint]

Aside from using the above to fix obvious problems, the Event Viewer contains very useful error codes and explanatory messages in well-formed English (which is just about a first for any Microsoft product, I think). Combination that + Google will provide fixes for most problems.

One thing I’ve seen once or twice is a certificate that the customer swears black-and-blue has been installed and it’s just not showing up in the Get-ExchangeCertificate output. If you look in (the Certificates snap-in in) MMC, it’s there. What’s happened? The customer requested the certificate in Exchange, but imported the certificate response in to MMC directly. Ergo, public and private keys not matched up and certificate not available to Exchange. Delete certificate from MMC, import in to Exchange instead.

Exporting certificates from a Java keystore

There is a patently easy way to convert JKS keystores to PKCS12 certificate bundles (and vice versa). It’s a (poorly documented) keytool command that was introduced with JDK 6:

Convert JKS to P12

keytool -importkeystore -srckeystore keystore.jks -srcstoretype JKS -deststoretype PKCS12 -destkeystore keystore.p12

Convert P12 to JKS

keytool -importkeystore -srckeystore keystore.p12 -srcstoretype PKCS12 -deststoretype JKS -destkeystore keystore.jks

Borrowed from a blog post by tomas at EJBCA.

Client Authentication for Apache 2

There are two ways to set up client authentication – the “correct” way (where you have all of your secured content in its own virtual host) and the “useful” way (where you want to have your secured content in a directory rather than the entire site).

The “useful” way involves renegotiating the SSL connection when accessing the secured content (i.e., the connection is negotiated once when you request and then renegotiated when you request This was all fine and well, but an OpenSSL vulnerability was discovered where renegotiation handshakes were not properly associated with the existing connection – thus potentially allowing for a Man-in-the-Middle attack.

OpenSSL 0.9.8m was released to fix the bug – the fix was to switch to a newer and more poorly supported method of allowing renegotiations. Practical outcome: client authentication in many web apps using Apache and mod_ssl simply stopped working.

Sometimes you need client authentication at a directory level, and chances are you want to make it work with commonly used web browsers (i.e., Internet Explorer). Here’s how you do it:

The method of configuring client authentication as described below intentionally turns back on a known security vulnerability in Apache. For obvious reasons, this isn’t recommended. If you can, set up your secured content in its own virtual host (the “correct” way).

This recipe makes use of the following ingredients:

  • Apache 2.2.15 or newer
  • OpenSSL (mod_ssl) 0.9.8m or newer

If you haven’t got the above two items, you need to fix that first.

Assumption: you’ve already got SSL set up and working – there are at least 9000 howto’s on the Internets, so little point in covering that here.

Once you have SSL working without error, you’ll need to add this to your VirtualHost configuration:

SSLVerifyClient require
SSLVerifyDepth x
SSLCACertificateFile /path/to/client-cert-issuing-chain.crt
SSLCADNRequestFile /path/to/client-cert-issuing-ca.crt
SSLInsecureRenegotiation on

The first line requires a certificate from the client.

The second line tells the server how far down it can traverse a chain to verify a certificate before giving up – 1 if the certificate is directly signed by a Root CA, 2 if there’s one Intermediate CA and so on.

The third line tells the server what CAs to trust for client authentication; if you have a chained hierarchy for issuing client certificates, this file should contain all of the Intermediate CAs up to and including the Root CA (concatenated together in PEM format). Not sure what version of Apache started requiring the full chain, but you’ll get non-obvious errors in your log files if you don’t have all of the CAs required here.

The fourth line tells the client what CAs the server will accept a certificate for, and should point to a file containing the Issuing CA (in PEM format) for your client certificates. This command is particularly important if you use an Intermediate CA to issue client certificates. It’s optional – and doesn’t get used to actually validate client certificates – but Internet Explorer pays attention to this statement when working out a list of acceptable client certificates for the user to pick from, so it’s not such a bad idea to include it.

The fifth line does exactly what it says; it’s what actually makes client authentication work at a directory level. Do note that the fifth line is only valid within a Server or Virtual Host context; you can’t use it in a Directory or Location section.

You will then need the following at the Directory level:

<FilesMatch “.(cgi|pl)$”>
SSLOptions +StdEnvVars

Obviously this is in addition to whatever else you have configured for the Directory section.

The first line requires a SSL’ed connection.

The FilesMatch section and SSLOptions statement aren’t absolutely required, but if you want to log any of the information from the client certificate the user is presenting, or make said information available in the environment variables – you’ll need it. Grabbing all this information comes at a performance penalty, so it makes good sense to restrict what types of files the server extracts it for.

Another item worth researching and including in your config is the SSLRequire directive – it’s reasonably complicated, but allows you to control what client certificates are allowed based on things like Subject DN and Issuer DN.

One last thing: make a point of reading the mod_ssl documentation. You’ll be glad you did!