Advertisement
Guest User

Untitled

a guest
Dec 10th, 2010
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. TCL error: Rule Enterprise_F5_Fix_with_E35-THD_cookie_encrypt HTTP_REQUEST - cant read cookie: no such variable while executing HTTP::cookie value $cookie
  2.  
  3.  
  4.  
  5. when CLIENT_ACCEPTED {
  6. # Define an AES encryption key. A 128 bit (or larger) key is recommended.
  7. # You can use a key generator, or create your own using only HEX characters.
  8. set aes_key "63544a5e7178677b45366b4140"
  9.  
  10. # Name of the cookie to encrypt/decrypt
  11. set cookie "app_cookie"
  12.  
  13. # Log debug messages to /var/log/ltm? 1=yes, 0=no.
  14. set cookie_encryption_debug 0
  15. }
  16. when HTTP_REQUEST {
  17. # If the error cookie exists with any value, for any requested object, try to decrypt it
  18. if {[string length [HTTP::cookie value $cookie]]}{
  19.  
  20. if {$cookie_encryption_debug}{log local0. \
  21. "Original error cookie value: [HTTP::cookie value $cookie]"}
  22.  
  23. # URI decode the value (catching any errors that occur when trying to
  24. # decode the cookie value and save the output to cookie_uri_decoded)
  25. if {not ([catch {URI::decode [HTTP::cookie value $cookie]} cookie_uri_decoded])}{
  26.  
  27. # Log that the cookie was URI decoded
  28. if {$cookie_encryption_debug}{log local0. "\$cookie_uri_decoded was set successfully"}
  29.  
  30. # Decrypt the value
  31. if {not ([catch {AES::decrypt $aes_key $cookie_uri_decoded} cookie_decrypted])}{
  32.  
  33. # Log the decrypted cookie value
  34. if {$cookie_encryption_debug}{log local0. "\$cookie_decrypted: $cookie_decrypted"}
  35. } else {
  36.  
  37. # URI decoded value couldn't be decrypted.
  38. }
  39. } else {
  40. # Cookie value couldn't be URI decoded
  41. }
  42. } else {
  43. # Cookie wasn't present in the request
  44. }
  45. if {[HTTP::uri] ends_with ".asmx?WSDL"}{
  46. set rewrite 1
  47. if { [HTTP::version] eq "1.1" } {
  48. HTTP::version "1.0"
  49. }
  50. } else {
  51. set rewrite 0
  52. }
  53. switch [getfield [string tolower [HTTP::uri]] "/" 2] {
  54. appe21test {pool test.app_EE_20 }
  55. appe21 { pool www.company.com_e20 }
  56. appe30 { pool www.company.com_e30 }
  57. appe30test { pool www.company.com_e30test }
  58. se08q4 { pool www.company.com_08q4 }
  59.  
  60. }
  61. }
  62. when HTTP_RESPONSE {
  63. # Check if response contains an error cookie with a value
  64. if {[string length [HTTP::cookie value $cookie]] > 0}{
  65.  
  66. # Log the original error cookie value from the app
  67. if {$cookie_encryption_debug}{log local0. \
  68. "Response from app contained our cookie: [HTTP::cookie value $cookie]"}
  69.  
  70. # Encrypt the cookie value so the client can't change the value
  71. HTTP::cookie value $cookie [URI::encode [AES::encrypt $aes_key [HTTP::cookie value $cookie]]]
  72.  
  73. # Log the encoded and encrypted error cookie value
  74. if {$cookie_encryption_debug}{log local0. \
  75. "Encrypted error cookie to: [URI::encode [AES::encrypt $aes_key [HTTP::cookie value $cookie]]]"}
  76. }
  77. if {$rewrite == 1}{
  78. # collect payload for URI replacement
  79. if {[HTTP::header exists Content-Length]}{
  80. set clength [HTTP::header Content-Length]
  81. } else {
  82. set clength 4294967295
  83. }
  84. if { !($clength == 0) } {
  85. HTTP::collect $clength
  86. }
  87. }
  88. }
  89. when HTTP_RESPONSE_DATA {
  90. set payload [HTTP::payload]
  91. regsub -all {(<soap:address location=\")(http://)(.*?\.asmx)} $payload "\\1https://\\3" payload
  92. HTTP::payload replace 0 [HTTP::payload length] $payload
  93. HTTP::release
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement