# InsertCertInServerHeaders

**URL:** <https://community.f5.com/t/insertcertinserverheaders/61102>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [December 28, 2009, 1:35pm UTC](https://community.f5.com/t/insertcertinserverheaders/61102 "2009-12-28T13:35:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![zafer](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zafer](https://community.f5.com/u/zafer)\
**Post date:** [December 28, 2009, 1:35pm UTC](https://community.f5.com/t/insertcertinserverheaders/61102/1 "2009-12-28T13:35:06Z")

</div>

Hello

i tested this rule, but it does not check empty Certificate from IE.

i tested with Firefox and i try send Empty certificate to the vip, Redirect works properly but when i tested with IE i can access the home page.its security hole

note: we need add this into the iRule

```tcl
} elseif { $ssl_errstr2 eq "" } { 
    HTTP::redirect "http://192.168.0.64/empty.html" 
    log local0. "client: [IP::remote_addr]:[TCP::remote_port] Empty certificate"

```

regards zafer

---

<div class="post-metadata">

**Author:** ![The\_Bhattman](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/the_bhattman/32/13958_2.png) [@The\_Bhattman](https://community.f5.com/u/The_Bhattman)\
**Post date:** [December 28, 2009, 8:20pm UTC](https://community.f5.com/t/insertcertinserverheaders/61102/2 "2009-12-28T20:20:53Z")

</div>

Hi Zafer,

What is the method of how you are checking the client cert? It would help if you can post the the entire iRule.

Bhattman

---

<div class="post-metadata">

**Author:** ![The\_Bhattman](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/the_bhattman/32/13958_2.png) [@The\_Bhattman](https://community.f5.com/u/The_Bhattman)\
**Post date:** [December 28, 2009, 8:23pm UTC](https://community.f5.com/t/insertcertinserverheaders/61102/3 "2009-12-28T20:23:32Z")

</div>

Nevermind. I never looked at the subject of your post.

Did you try putting space in the quotes?

I.E. $ssl\_errstr2 eq " "

Bhattman

---

<div class="post-metadata">

**Author:** ![zafer](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zafer](https://community.f5.com/u/zafer)\
**Post date:** [December 29, 2009, 6:10am UTC](https://community.f5.com/t/insertcertinserverheaders/61102/4 "2009-12-29T06:10:17Z")

</div>

Hi bhatman

i want to inform users this irule not check empty certificate comes from IE (i put link belove).

[http://devcentral.f5.com/Wiki/default.aspx/iRules/InsertCertInServerHeaders.html](http://devcentral.f5.com/Wiki/default.aspx/iRules/InsertCertInServerHeaders.html)

i added this lines these code and it works IE

} elseif { $ssl\_errstr2 eq “” } {

HTTP::redirect “[http://192.168.0.64/empty.html](http://192.168.0.64/empty.html)”

log local0. “client: [IP::remote\_addr]:[TCP::remote\_port] Empty certificate”

thats all

bhatman, i have problem with firefox i posted another message into the form, is that possible to help me

here is my post link

[http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=813947&view=topic](http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=813947&view=topic)

regards

zafer

---

<div class="post-metadata">

**Author:** ![The\_Bhattman](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/the_bhattman/32/13958_2.png) [@The\_Bhattman](https://community.f5.com/u/The_Bhattman)\
**Post date:** [December 29, 2009, 3:00pm UTC](https://community.f5.com/t/insertcertinserverheaders/61102/5 "2009-12-29T15:00:55Z")

</div>

I am sorry I am a bit confused because your first posting you had wrote that I.E. didn’t work- but now it does? Is Firefox the problem or IE or both?

Bhattman

---

<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 30, 2009, 12:21am UTC](https://community.f5.com/t/insertcertinserverheaders/61102/6 "2009-12-30T00:21:47Z")

</div>

Zafer,

Can you clarify how you were testing? Do you have the client SSL profile client cert option set to require or request? What type of test did you try when you encountered the issue?

Can you try this version of the client cert header insert rule. I think it covers more cases than the original version:

```tcl
client_cert_header_insert_rule 
  
 when CLIENTSSL_CLIENTCERT { 
  
     Check if client presented at least one cert 
    if {[SSL::cert count] > 0}{ 
  
        Insert the following fields in the session table with a timeout of 7200 seconds: 
          Do the processing now as opposed to in HTTP_REQUEST as there  
          can be many HTTP requests using the same SSL session ID 
        
          Index - item 
          0 - base64 encoding of the client SSL cert  
          1 - serial number of the cert 
          2 - the verification status text for the client cert against the client SSL profile's root CA cert 
       session add ssl [SSL::sessionid] [list \ 
          [SSL::verify_result] \ 
          [b64encode [SSL::cert 0]] \ 
          [X509::serial_number [SSL::cert 0]] \ 
       ] 7200 
  
       log local0. "[IP::client_addr]:[TCP::client_port]: Added session data for cert. Status:\ 
          [X509::verify_cert_error_string [lindex [session lookup ssl [SSL::sessionid]] 0]] with key [SSL::sessionid]" 
    } 
 } 
  
 when HTTP_REQUEST { 
  
     Check if SSL session ID is in the cache (SSL::sessionid returns 64 zeroes if it's not) 
    if {[SSL::sessionid] ne "0000000000000000000000000000000000000000000000000000000000000000"}{ 
  
        Get the session table entry (a TCL list) for this session ID 
       set session_data [session lookup ssl [SSL::sessionid]] 
  
        Check if the first element of the session table entry for this session ID is 0 (status for successful cert validation) 
       if {[lindex $session_data 0] == 0}{ 
  
          log local0. "[IP::client_addr]:[TCP::client_port]: Valid cert per session table entry. Inserting cert details in HTTP headers." 
  
           Insert cert details in the HTTP headers 
          HTTP::header insert SSLClientCertStatus "ok" 
          HTTP::header insert SSLClientCertb64 [lindex $session_data 1] 
          HTTP::header insert SSLClientCertSN [lindex $session_data 2] 
  
           Exit this event in this rule 
          return 
       } 
    } 
     If we're still in this rule, cert wasn't valid 
       so send HTTP 302 redirect to an error page 
    HTTP::respond "http://[HTTP::host]/cert_error.html" 
  
    log local0. "[IP::client_addr]:[TCP::client_port]: No or invalid cert from client." 
 }

```

Aaron

---

<div class="post-metadata">

**Author:** ![zafer](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zafer](https://community.f5.com/u/zafer)\
**Post date:** [January 4, 2010, 8:08am UTC](https://community.f5.com/t/insertcertinserverheaders/61102/7 "2010-01-04T08:08:43Z")

</div>

Hi Bhattman

if i use this iRule ([http://devcentral.f5.com/Wiki/default.aspx/iRules/InsertCertInServerHeaders.html](http://devcentral.f5.com/Wiki/default.aspx/iRules/InsertCertInServerHeaders.html)) i can bypass bigip with IE

i added this string ( } elseif { $ssl\_errstr2 eq “” } { ) into the iRule it works properly it can not bypass bigip with IE

regarding firefox without this string it works this is differences between IE and Firefox

regards

zafer

---

<div class="post-metadata">

**Author:** ![zafer](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zafer](https://community.f5.com/u/zafer)\
**Post date:** [January 4, 2010, 8:13am UTC](https://community.f5.com/t/insertcertinserverheaders/61102/8 "2010-01-04T08:13:02Z")

</div>

Hi Aaron

i will test your iRule and i will inform you asap

i have question about IE; When i request to the bigip withput Client Certificate, i see empty Certification request screen from IE but then click ok button.

What is differences between IE and Firefox at this point

Regarding multiple Client certificate request from Firefox, can i solve with this iRule.

regards

Zafer

---

<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:** [January 4, 2010, 11:13am UTC](https://community.f5.com/t/insertcertinserverheaders/61102/9 "2010-01-04T11:13:41Z")

</div>

Hi Zafer,

Can you try testing the above iRule I posted with IE and Firefox and reply with the results? If there are any issues, can you post the anonymized logs from /var/log/ltm and a description of the symptoms?

Thanks,

Aaron

---

<div class="post-metadata">

**Author:** ![Scot\_86001](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@Scot\_86001](https://community.f5.com/u/Scot_86001)\
**Post date:** [February 22, 2010, 3:22pm UTC](https://community.f5.com/t/insertcertinserverheaders/61102/10 "2010-02-22T15:22:01Z")

</div>

What versions is the above iRule supported under?

---

<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:** [February 22, 2010, 3:38pm UTC](https://community.f5.com/t/insertcertinserverheaders/61102/11 "2010-02-22T15:38:23Z")

</div>

Hi Scot,

That example I posted above ([Click here](http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=814019814125)) should work for 9.4.x. But it doesn’t do any enforcement based on the validation of the client cert against the trusted ca cert. Nor does it check the cert against an OCSP server. If you check your other post, I replied with a link to a Codeshare example I added that does validation of the client cert against the ca cert and one or more OCSP servers.

Aaron
