Forum Discussion
Joel_Moses
Nimbostratus
Mar 28, 2011TLS Server Name Indication iRule
http://devcentral.f5.com/wiki/default.aspx/iRules/TLS_ServerNameIndication.html
I posted the iRule above for discussion purposes. It decodes the TLS SNI extension field in an SSL/TLS negotiation and then attempts to dynamically switch the ClientSSL profile based on what it sees in this field. Essentially, this will allow you to use multiple certificates with a single VIP, dynamically switching them when the browser client changes the host it's requesting.
I'm intending to add support for changing pools as well -- that means that it's possible to support multiple certificates and multiple pools via a single VIP behind TLS encryption. But I thought I'd get this earlier proof of concept out there so people can see it and discuss it.
Joel
24 Replies
- Holy "Moses" just awesome :)
- Joel_Moses
Nimbostratus
Thanks, guys!
jquimby: Well, "binary scan" and its bitwise jump functions are pretty capable of replicating most of what pcap packet slicing can do; they just do it in a different syntax. For example a pcap "[13:2]" is pretty much equivalent to "binary scan [TCP::payload] @13S output". But I agree that it's not as easy to navigate for network folks who have had the pcap syntax firmly mashed into their brains through years of experience.
It'd be cool to have, say, a "TCP::payload match (pcap-style 'expr relop expr')" that would do the same thing as a binary scan but return just the bytes referenced -- that way you could take an existing pcap match rule and convert it.
I had to do this in CLIENT_DATA because it's pretty much the only place I can jump in before SSL/TLS negotiation. Really, though, I think it would be useful to create another iRules event: CLIENTSSL_HANDSHAKE_INIT. In the processing flow, this would happen after CLIENT_ACCEPTED and CLIENT_DATA, but just prior to CLIENTSSL_HANDSHAKE. It would essentially fire after the first ClientHello is collected but before it begins the handshake process. This would be a good place to grab and process TLS extensions, read the requested Cipherlist, and set variables to affect later script operation.
Some new commands would be needed: something like "SSL::extension" (giving access to TLS extension package data -- SNI included), "SSL::handshake cipherlist", and "SSL::handshake compressionlist". In addition to giving access to the ServerName extension early, this could also allow you to select the "strongest" ClientSSL profile _manually_ based on what the client's proposed cipherlist. Other extensions would be useful to obtain early on: max_fragment_length, trusted_ca_keys, and ocsp_status_request.
There are always ways to make things easier for the administrator, but to F5's credit, I've run into very little that I can't accomplish using an iRule or two... Kudos, guys! - Colin_Walker_12Historic F5 AccountPiling on here: Wicked cool stuff. Keep up the good work.
Colin - JRahm
Admin
Posted By Joel Moses on 03/30/2011 03:37 PM
Thanks, guys!
jquimby: Well, "binary scan" and its bitwise jump functions are pretty capable of replicating most of what pcap packet slicing can do; they just do it in a different syntax. For example a pcap "[13:2]" is pretty much equivalent to "binary scan [TCP::payload] @13S output". But I agree that it's not as easy to navigate for network folks who have had the pcap syntax firmly mashed into their brains through years of experience.
It'd be cool to have, say, a "TCP::payload match (pcap-style 'expr relop expr')" that would do the same thing as a binary scan but return just the bytes referenced -- that way you could take an existing pcap match rule and convert it.
I had to do this in CLIENT_DATA because it's pretty much the only place I can jump in before SSL/TLS negotiation. Really, though, I think it would be useful to create another iRules event: CLIENTSSL_HANDSHAKE_INIT. In the processing flow, this would happen after CLIENT_ACCEPTED and CLIENT_DATA, but just prior to CLIENTSSL_HANDSHAKE. It would essentially fire after the first ClientHello is collected but before it begins the handshake process. This would be a good place to grab and process TLS extensions, read the requested Cipherlist, and set variables to affect later script operation.
Some new commands would be needed: something like "SSL::extension" (giving access to TLS extension package data -- SNI included), "SSL::handshake cipherlist", and "SSL::handshake compressionlist". In addition to giving access to the ServerName extension early, this could also allow you to select the "strongest" ClientSSL profile _manually_ based on what the client's proposed cipherlist. Other extensions would be useful to obtain early on: max_fragment_length, trusted_ca_keys, and ocsp_status_request.
There are always ways to make things easier for the administrator, but to F5's credit, I've run into very little that I can't accomplish using an iRule or two... Kudos, guys! Some of your ideas here are already under consideration in development. The pcap idea is a good one, and has a couple of developers asking questions. Nice work. - Joel_Moses
Nimbostratus
That's great! Let me know if you guys need a sounding board for this.
It occurred to me in the Advanced Design forum where I saw someone asking about a layer 2 forwarding virtual server and SSL offload -- a CLIENT_HANDSHAKE_INIT event would be an interesting place to switch clientSSL profiles _and_ pool assignments on the fly based on either SNI _or_ the destination IP address; letting you switch the SSL cert _and pool_ presented based on either item. That could be useful when inserting ASM in the route path in front of an _existing_ secure web server network. - Colin_Walker_12Historic F5 AccountWe'll definitely let you know if any specific questions bubble up. We try and ping the community whenever we can to get opinions on that kind of stuff when we get the chance.
Thanks again for the input/work so far.
Colin - Kevin_Davies_40
Nacreous
I realise that this is 4 months down the track but would an RFE on SNI/SSL profile selection go astray? This will become very common in the future.FYI: The original article in the first post seems to have gone astray.
Kevin (Jarvil) - hoolio
Cirrostratus
Hi Kevin,
I think we have an existing RFE for native TLS SNI support. I don't have it handy, but Support could find it for you. Another case would always be good.
If you get the RFE ID could you reply back here?
Thanks, Aaron - Mauz
Altostratus
I have a server with 1024-bit certificate and i need to migrate to 2048 bit certificate. Can i use the TLS SNI feature in version 11.2 to help in this migration?
I am wondering if I put my 2048 bit certificate (with TLS SNI ) as the first SSL profile in my VS, and have the 1024-bit in the failback ssl profile.
Can I use the same DNS name for both certificates?
Even if it works, I am worried that some of the clients may not like the extra SSL SNI negotiation going on the LTM. Has anyone come across failures where some clients could not connect, especially that I am using some dumb terminals as clients ?
thanks - Kevin_Stewart
Employee
The TLS Server Name extension allows the client to specify the server name in the CLIENTHELLO message, so SNI wouldn't work for you if both server certs had the same name. If both server certs are signed by the same issuer, or rather if both certs are signed by CAs that the clients explicitly trust, then you shouldn't have to do anything other than just replace the server cert.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
