# iRule help

**URL:** <https://community.f5.com/t/irule-help/6314>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [December 14, 2011, 1:16pm UTC](https://community.f5.com/t/irule-help/6314 "2011-12-14T13:16:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cisco2F5\_16233](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Cisco2F5\_16233](https://community.f5.com/u/Cisco2F5_16233)\
**Post date:** [December 14, 2011, 1:16pm UTC](https://community.f5.com/t/irule-help/6314/1 "2011-12-14T13:16:37Z")

</div>

My name is Will i just finished both my F5 classes Essentials - V10v and Advanced Topics - V10 Now i am being thrown into the fire as they say and i need some help with this irule.

What this irule should do is

"sets a varable called cert to the cert that comes in…

uses that to set session persistance for 180 seconds.

sets another varable called clientip from the connected ip…

then some logging, if the varable cert isn’t empty, add a log that says cert sent.

else, ie if it is empty set a log that say no cert."

This is what is was in v9 and worked perfectly

when CLIENTSSL\_CLIENTCERT {

set cert [SSL::cert 0]

session add ssl [SSL::sessionid] $cert 180

set clientip [IP::remote\_addr]

if { $cert ne “”} {

log local0. “iRULE:ClientIP:$clientip | Status: Cert Sent”

} else {

log local0. “iRULE:ClientIP:$clientip | Status: No Cert”

reject

return

}

}

}

when HTTP\_REQUEST {

set client\_cert [session lookup ssl [SSL::sessionid]]

set hash [X509::hash $client\_cert]

if { [info exists hash] } {

HTTP::header replace NETWORK\_ALIAS $hash

log local0. “iRULE:Inserting HTTP header client $clientip Cert Hash: $hash”

}

}

}

Now this irule no longer works in v10

Thank you in advance for your help!

---

<div class="post-metadata">

**Author:** ![Michael\_Yates](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@Michael\_Yates](https://community.f5.com/u/Michael_Yates)\
**Post date:** [December 14, 2011, 1:52pm UTC](https://community.f5.com/t/irule-help/6314/2 "2011-12-14T13:52:28Z")

</div>

Hi Cisco2F5,

The SSL::sessionid behavior has changed in v10.x.x which might be causing some strange behavior.

See the Wiki Entry for it here: [SSL::sessionid](http://devcentral.f5.com/wiki/iRules.SSL__sessionid.ashx)

Returns the current connection’s SSL session ID if it exists in the session cache.

In version 10.x, if the session ID does not exist in the cache, returns a null string.

In version 9.x, if the session ID does not exist in the cache, returns a string of 64 zeroes. (This Known Issue is documented in SOL11987 )

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Cisco2F5\_16233](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Cisco2F5\_16233](https://community.f5.com/u/Cisco2F5_16233)\
**Post date:** [December 14, 2011, 2:44pm UTC](https://community.f5.com/t/irule-help/6314/3 "2011-12-14T14:44:34Z")

</div>

Thank you ..ill try that out..

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [December 14, 2011, 3:35pm UTC](https://community.f5.com/t/irule-help/6314/4 "2011-12-14T15:35:58Z")

</div>

I agree with Michael on this. One issue with that iRule is that SSL::sessionid will return a null string instead of 64 zeroes if the client’s session ID doesn’t exist in TMM’s cache.

That said, you should also add a check to see that the cert count is \> 0 before adding anything to the session table. And you should check in HTTP\_REQUEST to see that the session ID is not null before attempting a session lookup.

You could modify this Codeshare example to fit your scenario:

[http://devcentral.f5.com/wiki/iRules.InsertCertInServerHeaders.ashx](http://devcentral.f5.com/wiki/iRules.InsertCertInServerHeaders.ashx)

AAaron
