Forum Discussion

Paul_Risk_10960's avatar
Paul_Risk_10960
Icon for Nimbostratus rankNimbostratus
Sep 19, 2007

Need to use the special character "$" in an HTTP header name?

Hi guys,

 

 

I need to pass the client cert in an HTTP header to the backend server. I have a working iRule that does this perfectly (from DevCentral :D ), however I need to call the HTTP header "$WSCC" and $ is obviosuly a special character. When I use the iRule below, I get this error in the logs (which I totally understand):

 

 

TCL error: Rule test_cert - can't read "WSCC": no such variable while xecuting "HTTP::header replace $WSCC [X509::whole $the_cert]"

 

 

 

So how can I define an HTTP header called "$WSCC" (without the quotes)?

 

 

This is the current iRule:

 

 

when CLIENTSSL_HANDSHAKE {

 

set cur [SSL::sessionid]

 

set ask [session lookup ssl $cur]

 

if { $ask eq "" } {

 

session add ssl [SSL::sessionid] [SSL::cert 0]

 

}

 

}

 

when HTTP_REQUEST {

 

set id [SSL::sessionid]

 

set the_cert [session lookup ssl $id]

 

if { $the_cert != ""}

 

{

 

HTTP::header replace $WSCC [X509::whole $the_cert]

 

log "Client cert is $the_cert"

 

}

 

else { log "no client cert found!" }

 

}

 

 

 

Thanks,

 

Risky.
  • So it appears the answer is simple. Just put a \ in front of the name - so in this case the iRule statement should read:

     

     

    HTTP::header replace \$WSCC [X509::whole $the_cert]

     

     

    Tested this and it works fine.

     

     

    Risky.