# insert http-header value from SSL Certificate extentions

**URL:** <https://community.f5.com/t/insert-http-header-value-from-ssl-certificate-extentions/44505>\
**Category:** Technical Forums\
**Created:** [June 17, 2015, 8:50am UTC](https://community.f5.com/t/insert-http-header-value-from-ssl-certificate-extentions/44505 "2015-06-17T08:50:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juergen\_lampar1](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@juergen\_lampar1](https://community.f5.com/u/juergen_lampar1)\
**Post date:** [June 17, 2015, 8:50am UTC](https://community.f5.com/t/insert-http-header-value-from-ssl-certificate-extentions/44505/1 "2015-06-17T08:50:49Z")

</div>

Hi, i need insert the email-address from CLient Certificate in the http-header to the real server. my irule write only empty header:

when CLIENTSSL\_CLIENTCERT { set search\_ext\_attribute “email:” set search\_ext\_length [string length $search\_ext\_attribute] set the\_cert [SSL::cert 0] if {[SSL::cert count] \> 0}{ set ext\_attribute [findstr [X509::extensions [SSL::cert 0]] $search\_ext\_attribute $search\_ext\_length " " session add ssl [SSL::sessionid] $ext\_attribute } } when HTTP\_REQUEST { set header\_ext\_email “x-http-email” if {[SSL::sessionid] ne “”}{ set ssllist [session lookup ssl [SSL::sessionid]] set ext\_attribute [lindex ssllist 1] if { [SSL::cert count] \> 0} { set the\_cert [SSL::cert 0] HTTP::header insert $header\_ext\_email [getfield $ext\_attribute “,” 1] } } }

Why?

---

<div class="post-metadata">

**Author:** ![boneyard](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/boneyard/32/20419_2.png) [@boneyard](https://community.f5.com/u/boneyard)\
**Post date:** [June 21, 2015, 6:55pm UTC](https://community.f5.com/t/insert-http-header-value-from-ssl-certificate-extentions/44505/2 "2015-06-21T18:55:00Z")

</div>

have you tried basic debugging yourself? if not this is how i much approach this

start with logging the X509::extensions to see if the email is available there

then check if you filter it correctly to ext\_attribute, i believe that line is missing a ]

then why do you put it in a you got your email, which you can insert in your header without making it extra complex.

---

<div class="post-metadata">

**Author:** ![juergen\_lampar1](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@juergen\_lampar1](https://community.f5.com/u/juergen_lampar1)\
**Post date:** [June 29, 2015, 8:54am UTC](https://community.f5.com/t/insert-http-header-value-from-ssl-certificate-extentions/44505/3 "2015-06-29T08:54:57Z")

</div>

Hi,

now is the irule running, but i have a other problem. Our Application need the http-header everytime, not only while new connect or ssl session ID changes. Have anyone a idea?

```tcl
when CLIENTSSL_CLIENTCERT {
    set search_cn_attribute "emailAddress="
    set search_cn_length [string length $search_cn_attribute]
    set cn_attribute ""
    if {[SSL::cert count] > 0} {
        set cert_subject [split [X509::subject [SSL::cert 0]] ","]
                foreach subject_attribute $cert_subject {
            if {$subject_attribute starts_with $search_cn_attribute} {
                if {$cn_attribute eq ""} {
                    append cn_attribute "[findstr $subject_attribute $search_cn_attribute $search_cn_length]"
               } else {
                                        append cn_attribute ","
                    append cn_attribute "[findstr $subject_attribute $search_cn_attribute $search_cn_length]"
               }
            }
        }
            session add ssl [SSL::sessionid] $cn_attribute
    } else {
        }
}
when HTTP_REQUEST {
    set header_cn_info "x-http-authinfo"
    if {![info exists cn_attribute]} {
        set cn_attribute ""
    }
    if {[HTTP::header exists $header_cn_info]} {
        HTTP::header remove $header_cn_info
    }
    HTTP::header insert $header_cn_info [getfield $cn_attribute "," 1]
}

```

---

<div class="post-metadata">

**Author:** ![Ronald\_van\_der3](https://avatars.discourse-cdn.com/v4/letter/r/9dc877/32.png) [@Ronald\_van\_der3](https://community.f5.com/u/Ronald_van_der3)\
**Post date:** [June 29, 2015, 9:02am UTC](https://community.f5.com/t/insert-http-header-value-from-ssl-certificate-extentions/44505/4 "2015-06-29T09:02:57Z")

</div>

Sounds like you have an issue with session handling in your application? I would recommend to fix this issue in the application instead of building a workaround (which can be ‘mis’-used by other users) in LTM.
