Forum Discussion

Michael_A__Fied's avatar
Michael_A__Fied
Icon for Nimbostratus rankNimbostratus
Jun 23, 2009

Broken b64 decoding

Following this article:

 

http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenancePage.html

 

 

I have a nicely implemented maintenance page.

 

 

I want to add a new png file in b64 encoding, and all went well except that the decoding seems to break about 30% down.

 

 

The image is about 700x700 pixels, in png format. Using the web-based decoder at http://www.motobit.com/util/base64-decoder-encoder.asp I can confirm that the file is b64 encoded and decoded properly.

 

 

File size is about 95k - is that even a factor?

 

 

Any ideas would be great at this point.

8 Replies

  • I haven't seen any posts about the base64 decode failing. Maybe it's the format of the encoded string in the file? It should be in the format of:

     

     

    "base64encodedtext",

     

     

    with no new lines or carriage returns in between the double quotes.

     

     

    If that doesn't solve the problem, can you elaborate on how the decoding is breaking 30% through the image?

     

     

    Aaron
  • The image has been properly formatted with quotes and comma. We use other images that work just fine (albeit they are smaller images).

     

     

    The image properties are transmitted correctly - pixels of size (683 x 730).

     

     

    The first 200 or so pixels are rendered correctly, and then the rest is shown as white.

     

     

    I took the same properly formatted string, used the online decoder, and it renders correctly.
  • Are there any spaces in the base64 encoded text? If so, I think they'd need to be replaced with +. Are you okay with posting the encoded text?

     

     

    Aaron
  • Could it be due to there are '\r' characters in your base64? What about trying to remove it in step 4:

     

     

    tr -d '\n|\r' < file_with_newlines > file_without_newlines

     

     

    Or, try to verify your base64 in LTM (eg. file_with_newlines):

     

     

    openssl enc -d -base64 -in file_with_newlines -out file.png
  • Correction, the tr command should be:

     

     

    tr -d '\n\r' < file_with_newlines > file_without_newlines
  • Or, copy the png file (eg. image.png) to LTM and run this:

     

     

    openssl enc -base64 -in image.png | tr -d '\n' > /var/class/maint.logo.png.class

     

     

    Sorry for spamming :D
  • Thanks y'all for your assistance - the file was formatted correctly all along from the get-go.

     

     

    Seems like there's a upper limit on the size of an external class file.

     

     

    From F5 Support:

     

    One of my colleagues is working on an AskF5 solution article, but it is not yet ready for publication. He tells me that the maximum size of a list item (not including the surrounding double-quotes and trailing comma) is 65520 bytes.

     

     

     

    So all we did was split the file into smaller segments and it worked just fine.