Fortinet white logo
Fortinet white logo

Script Reference Guide

HTTP:cookie_crypto(t)

HTTP:cookie_crypto(t)

The provided function response_encrypt_cookie can be used to perform cookie encryption in HTTP_RESPONSE and request_decrypt_cookie can be used to perform cookie decryption in HTTP_REQUEST.

Syntax

HTTP:cookie_crypto(t);

Arguments

Name Description

t

A table which specifies cookie name, parameter, action.

Events

Applicable in the following events:

  • HTTP_REQUEST

  • HTTP_RESPONSE

Example

when HTTP_REQUEST {
--encrypt cookie "test" in HTTP REQUEST before forwarding to real servers
local t={};
t["name"]="cookiename"
t["action"]="encrypt"      --encrypt, or decrypt
t["key"]="0123456789ABCDEF";
t["prefix"]="XXXX";
t["size"]=size-- 128, 192, or 256, the corresponding key length is 16, 24, and 32
if  HTTP:cookie_crypto(t) then
debug("Encrypt cookie succeed\n");
else
debug("Encrypt cookie failed\n");
end
}

Note:

  • name: specify cookie name
  • action: can be encrypt, or decrypt
  • size: can be 128, 192, or 256, the corresponding key length is 16, 24, and 32

Supported Version

FortiADC version 5.2.x and later.

HTTP:cookie_crypto(t)

HTTP:cookie_crypto(t)

The provided function response_encrypt_cookie can be used to perform cookie encryption in HTTP_RESPONSE and request_decrypt_cookie can be used to perform cookie decryption in HTTP_REQUEST.

Syntax

HTTP:cookie_crypto(t);

Arguments

Name Description

t

A table which specifies cookie name, parameter, action.

Events

Applicable in the following events:

  • HTTP_REQUEST

  • HTTP_RESPONSE

Example

when HTTP_REQUEST {
--encrypt cookie "test" in HTTP REQUEST before forwarding to real servers
local t={};
t["name"]="cookiename"
t["action"]="encrypt"      --encrypt, or decrypt
t["key"]="0123456789ABCDEF";
t["prefix"]="XXXX";
t["size"]=size-- 128, 192, or 256, the corresponding key length is 16, 24, and 32
if  HTTP:cookie_crypto(t) then
debug("Encrypt cookie succeed\n");
else
debug("Encrypt cookie failed\n");
end
}

Note:

  • name: specify cookie name
  • action: can be encrypt, or decrypt
  • size: can be 128, 192, or 256, the corresponding key length is 16, 24, and 32

Supported Version

FortiADC version 5.2.x and later.