https://blogs.technet.microsoft.com/nettracer/2013/12/30/how-it-works-on-the-wire-iis-http-client-certificate-authentication/
This looked exactly like what I was looking for, a packet capture of client certificate authentication.
The link said that there’s something going on with SSL protocol, and client certificates are handled as a part of it as shown in the image below:
As seen above the “Certificate Request” is part of the Handshake Protocol, I kept searching for more information and got to an article titled “How SSL/TLS Works?” which dated back to 2003. This article turned out to be one of the best sources of information on this topic which depicted clearly how the protocol works.
As defined in RFC 5246, TLS Protocol v1.2 there are two sub protocols for TLS, one being the handshake protocol and the other being the record protocol.
“SSL/TLS Protocol” messages are show below in the form of Sender -> Receiver, messages that are directly related to “Client Certificate Authentication” are marked as red:
1. Client -> Server: “Client Hello” message which contains:
2. Server -> Client: “Server Hello“:
2.1. Server Certificate:
2.2. Server Key Exchange Message (Optional):
2.3. Client Certificate Request Message (Optional):
2.4. Server Hello Done
3. Client->Server: Client Certificate Message (Required if requested):
3.1. Client Key Exchange:
3.2 Certificate Verify Message (Required if Client Certificate is sent)
3.3. Change Cipher Spec:
4. Server-> Client: Server Finished:
4.1. Finished:
5. Application Data Flow
The answer is, yes!
Item 3.2 in TLS protocol definition simply tells us that TLS traffic that contains Client Certificates contains session specific data and dealing with it requires much more than simply decrypting and re-encrypting the traffic at WAF and sending it to the web server. At this point after discussing this information with the companies’ developers they estimated that implementing this feature in their WAF is going to take some time and effort. So we started looking for alternatives.
After some research I found some devcentral (F5) forum posts claiming that iRules can be used in order to read the client certificate and add a custom header to http requests which the webserver could interpret and authenticate the clients. This would require the web application to undergo some changes in its authentication mechanism and was not the perfect solution. Under one of these posts someone said that in newer firmware versions of BIG-IP you can use a feature called “Proxy SSL” to have an end-to-end SSL session to your webserver and not worry about client certificates. This was the thing! (Youtube video explaining Proxy SSL Feature)
The design for SSL’s client certificate authentication prevents you from doing a man-in-the-middle at your WAF or any other intermediary device. What F5 Big-IP does is that takes the server’s certificates and keys from you asks you to disable ephemeral keys allowing only RSA to be used and then it gets to decrypt the SSL session and inspect the traffic applying its WAF rules while leaving the main traffic intact and the channel between client to IIS doesn’t get tampered with.
It’s rather easy to setup Big-IP using a guide like this. Briefly speaking the steps are as follows:
Under Local Traffic>Profiles>SSL, you need to create both the Client and Server SSL Profiles.
First you need to import your SSL Certificates to your BIG-IP. Export them from your web server along with its private key and import them to your device.
Creating Client SSL Profile:
Creating Server SSL Profile:
The Virtual Server has to use these profiles. Client SSL Profile is responsible for the traffic between the client (end-user) and BIG-IP while the Server SSL Profile is responsible for the traffic between BIG-IP and your web server.
In order for BIG-IP to be able to decrypt and inspect the traffic you have to disable DH and Ephemeral Keys. I’ll show you how to do this under Windows Server/IIS, the same procedure has to be done for Apache, Nginx and other web servers.
SSL settings, namely versions, cipher suites, key exchange algorithms and hash functions are configured in Schannel under registry. One easier method for modifying these settings is to use Nartac IIS Crypto software to set things up using the GUI.
As depicted, only RSA cipher suites are left enabled along with PKCS key exchange algorithm.
Now your users can use their client certificates to authenticate themselves to the web server while BIG-IP ASM is actively applying rules and signatures to the traffic.