Forum Discussion
Check the VS port to determine if connection is SSL or not, help me to fix it
when CLIENT_ACCEPTED {
Check the VS port to determine if connection is SSL or not
switch [TCP::local_port] { "443" { set proto "https" } default { set proto "http" } }} when HTTP_RESPONSE { set chk_cookies [HTTP::cookie names] foreach cookie $chk_cookies { Rewrite Cookies to ensure the version is Cookie version is correct set cookie_value [HTTP::cookie $cookie] HTTP::cookie remove $cookie HTTP::cookie insert name $cookie value $cookie_value path / version 1 Set HttpOnly for all cookies HTTP::cookie httponly $cookie enable Set Secure if connection is SSL if {$proto=="https"}{ HTTP::cookie secure $cookie enable } }}
1 Reply
Hi jaiAdityaSingla,
I would change the code to...
when CLIENT_ACCEPTED { Check the VS port to determine if connection is SSL or not if { [TCP::local_port] eq "443" } then { set secure_cookie "; Secure" } else { set secure_cookie "" } } when HTTP_RESPONSE { foreach temp(cookie) [HTTP::cookie names] { Rewrite Cookies to ensure the version is Cookie version is correct set temp(cookie_value) [HTTP::cookie $cookie] HTTP::cookie remove $cookie HTTP::header insert Set-Cookie "$temp(cookie)=\"$temp(cookie_value)\"; Version=1; HttpOnly$secure_cookie; Path=/" } }Note1: The code would insert a raw Set-Cookie header, with precomputed cookie options.
Note2: The "; Secure" option is getting substituted using the results of the CLIENT_ACCEPTED event.
Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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