Forum Discussion

Doug_Lohf_88372's avatar
Doug_Lohf_88372
Icon for Nimbostratus rankNimbostratus
Oct 07, 2005

Encrypt HTTP body?

I know this sounds strange but is it possible to only encrypt only the body of an http packet with an iRule? The client at the far end is not a browser but a custom client.
  • Yes, very strange...Today, the webserver will encrypt the data portion of a port 80 packet and a custom client will decrypt the data portion. Looking to offload the encryption from the webserver. The client can be changed to accommodate certain encryption schemes if necessary. The reason for port 80 is to bypass corporate firewalls...
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Try something like this:

    
    when HTTP_REQUEST {
        Don't allow data to be chunked
       if { [HTTP::version] eq "1.1" } {
          if { [HTTP::header is_keepalive] } {
             HTTP::header replace "Connection" "Keep-Alive"
          }
          HTTP::version "1.0"
       }
    }
    when HTTP_RESPONSE {
       if { [HTTP::header exists "Content-Length"] } {
          set content_length [HTTP::header "Content-Length"]
       } else {
          set content_length 4294967295
       }
       if { $content_length > 0 } {
          HTTP::collect $content_length
       }
    }
    when HTTP_RESPONSE_DATA {
       set encrypted [b64encode [AES::encrypt "passphrase" [HTTP::payload]]]
       HTTP::payload replace 0 [HTTP::payload length] $encrypted
    }