cancel
Showing results for 
Search instead for 
Did you mean: 

Using TrafficScript to analyze client TLS Server Name support (10/05/2009)

crispin
Not applicable

Using TrafficScript to analyze client TLS Server Name support (10/05/2009)

146_23464.png

TrafficScript is very powerful at manipulating requests and responses, however it can also be used to analyze clients to see what functionality they support. In particular in this article we will look at the TLS Server Name Extension, using TrafficScript to see the percentage of clients that support the feature.

One major disadvantage with the original SSL and TLS specification was that it required one IP address per encrypted service. This limitation arises as a result of the the clients needing to validate the certificate presented by the server. The only way for the server to know which certificate to present was based on the IP address that the client connected to (an alternative is wild-carded certificates which I won't touch on here).

Back in the dark ages (well, 2003), an extension was added to TLS 1.0 that gave a way for the client to provide the server with the hostname for which to provide the certificate. It has taken a while for this extension to be implemented in browsers such as Internet Explorer and Firefox, and longer still for end users to upgrade.

TLS Server Name extension support was added to SXTM in version 5.1, and can be configured from the Virtual Server -> Edit -> SSL decryption page (use host names rather than IP addresses to select the certificate to send to the client). However, except in tightly controlled environments, I wouldn't recommend it currently be used.

Even if you don't use the support inside SXTM you can still use TrafficScript to see if your clients support the extension:

  1. # Don't run this rule for non SSL decrypting traffic
  2. if( ! ssl.isSSL() ) break;
  3. if( ssl.getTLSServerName() == "" ) {
  4.    log.info( "TLS Server name not supported" );
  5. } else {
  6.    log.info( "TLS Server name supported" );
  7. }

What this rule will show you is FireFox has supported it since version 2.0, but Internet Explorer hasn't properly supported it on XP until version 8. The gory details are on the Wikipedia page.

A slight modification to the rule allows you to count the number of clients that support the extension:

  1. # Don't run this rule for non SSL decrypting traffic
  2. if( ! ssl.isSSL() ) break;
  3. if( ssl.getTLSServerName() == "" ) {
  4.    counter.increment( 0 );
  5. } else {
  6.    counter.increment( 1 );
  7. }

Using the above rule you can graph user counters 0 and 1 in the Current Activity page of the administration server to see the ratio of users of your site that use clients that support the extension. You can also get the raw numbers using SNMP.

As with most little TrafficScript rules they tend to grow over time. In the end I ended up with a rule that periodically logs the user agents to the event log that support and don't support the extension. This is great for testing but I wouldn't recommend it on a production site:

  1. # Don't run this rule for non SSL decrypting traffic
  2. if( ! ssl.isSSL() ) break;
  3. if( ssl.getTLSServerName() != "" ) {
  4.    # This client supports the TLS Server Name extension
  5.    counter.increment( 1 );
  6.    log.info.limit( "TLS Server Name supported by: " . getuseragent(), 60 );
  7. } else {
  8.    # This client does not support the TLS Server Name Extension
  9.    log.info.limit( "No TLS Server Name support from: " . getuseragent(), 60 );
  10.    counter.increment( 0 );
  11. }
  12. # Get the user agent from the HTTP headers
  13. sub getuseragent()
  14. {
  15.    return  http.getheader( "User-Agent" ) || "unknown user agent";
  16. }
  17. # Call log.info for an indivdual msg once per $interval time
  18. sub log.info.limit($msg, $interval)
  19. {
  20.    $last = data.get( "limit!" . $msg );
  21.    if( ! $last || $last > sys.time() - $interval ) {
  22.       log.info( $msg );
  23.       data.set( "limit!" . $msg, sys.time() );
  24.    }
  25. }

In an ideal world, you would find that all your clients supported the extension, and you could then reduce IP address usage and potentially save some money, in practice, though you will probably find that 50% of your users don't support the extension currently.

Hopefully in 5 years time we will all be able to use the extension as it was originally intended...

1 Comment
olowokandi
Occasional Contributor

does  counter.increment sync across a active active cluster? or is it specific to each stingray instance?