Forum Discussion
sam_111661
Nimbostratus
Dec 02, 2008HTTP::cookie and decryption
I'm trying to avoid authenticating each and every get / post in the HTTP request using cookies, I would be grateful if anybody could explain to me whats wrong here
The domain is correct, the client receives the cookie and sends it back with the next request but the HTTP::cookie decrypt is not decrypting it correctly, logs are below the iRule. If I disable encrypting / decrypting everything works fine
when CLIENT_ACCEPTED {
set authinsck 0
set forceauth 1
set ckname BIGXAUTH
set ckpass 12345678
set ckvalue [IP::client_addr]
set ckdomain 192.168.1.10
set asid [AUTH::start pam default_ldap]
}
when HTTP_REQUEST {
if {[HTTP::cookie exists $ckname]} {
log "HTTP cookie sent in request is [HTTP::cookie $ckname]"
HTTP::cookie decrypt $ckname $ckpass 128
log "decrypted cookie is: [HTTP::cookie decrypt "$ckname" "$ckpass" 128]"
if {[HTTP::cookie value $ckname] eq $ckvalue} {
set forceauth 0
}
HTTP::cookie remove $ckname
}
if {$forceauth eq 1} {
AUTH::username_credential $asid [HTTP::username]
AUTH::password_credential $asid [HTTP::password]
AUTH::authenticate $asid
HTTP::collect
}
}
when HTTP_RESPONSE {
if {$authinsck eq 1} {
HTTP::cookie insert name $ckname value $ckvalue path / domain $ckdomain
HTTP::cookie secure $ckname enable
HTTP::cookie encrypt $ckname $ckpass 128
log "HTTP cookie sent in response is [HTTP::cookie encrypt $ckname $ckpass 128]"
}
}
when AUTH_SUCCESS {
if {$asid eq [AUTH::last_event_session_id]} {
set authinsck 1
HTTP::release
}
}
Dec 3 00:19:01 tmm tmm[17530]: 01220002:6: Rule http_cookie : HTTP cookie sent in response is ROteWMN4zP5XoReq3pkmwJ4509NFp0OGWXYf/9mdXJaF8xb8IAFZOJby7eZfEqw6T2nZ8DNz0veF2wK1qVrZ5Fm6WmqSzMpMziJbddPDbnVqmPGhmxfESId9zTz+/ntBN58Y/i/+KUNyGQ==
Dec 3 00:19:01 tmm tmm[17530]: 01220002:6: Rule http_cookie : HTTP cookie sent in request is ROteWMN4zP5XoReq3pkmwJ4509NFp0OGWXYf/9mdXJaF8xb8IAFZOJby7eZfEqw6T2nZ8DNz0veF2wK1qVrZ5Fm6WmqSzMpMziJbddPDbnVqmPGhmxfESId9zTz+/ntBN58Y/i/+KUNyGQ==
Dec 3 00:19:01 tmm tmm[17530]: 01220002:6: Rule http_cookie : decrypted cookie is:
- Colin_Walker_12Historic F5 AccountThat's quite odd, you're right. The syntax looks correct, and I'm surprised you're not seeing any output from the decrypt command. Are there any other log entries being generated?
- sam_111661
Nimbostratus
Thanks Colin, can't see anything else in the logs, I'm running this version - sam_111661
Nimbostratus
If I use the AES::decrypt everything works fine but I understand from the wiki that the recommended method is HTTP::cookie decrypt - c_p_i_o_17707Historic F5 AccountThis is a bug in the product. This issue has been resolved in 9.4.5 (CR95909).
- c_p_i_o_17707Historic F5 AccountYou're right, CR95909 is missing from the release notes for 9.4.5. Probably an oversight. This works fine in stable 9.3.1. Only 9.4.x to 9.4.4 seems to be affected.
- sam_111661
Nimbostratus
no encryption / decryption:
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects