problems with b64decode decoding signed content

we need to decode a uri from Microsoft owa where the result has about 41 binary Bytes for a signature. we only need the rest but the base64 fails with

conversion error (line 1) invoked from within “b64decode $uri”

i also tried to fix it using substr to cut the binary part Prior to the base64decode without success

any idea?

Are you able to provide an example of what $uri contains when the decode fails ?

I expected that question :slight_smile: sorry no, because in the result are informations i cannot put in a public blog (company policy)

Is your uri url-encoded (after the b64-encoding)? I have seen similar error when trying to b64-decode an uri without first url-decoding it.

Url-encoding replaces unsafe ASCII characters with a “%” followed by two hexadecimal digits, to make it safe to be used in http requests. Trying to b64-decode url-encoded string can fail in this case.

For example b64encode will add padding depending on the length of the string to be encoded. Sometimes padding is “=” -characters in the end of the b64 string, and those are not good in the uri.

Example: set decoded_uri [b64decode [URI::decode [HTTP::uri]]

the solution can be found in wiki where they describe base64 and “URL applications”, and the iRule translation is:

set uri [string map {- +} $uri]
    set uri [string map {_ /} $uri]