DataPower

 View Only
Expand all | Collapse all

Getting error "Valid base64 passed to dp:decode resulted in non UTF8" in Datapower

  • 1.  Getting error "Valid base64 passed to dp:decode resulted in non UTF8" in Datapower

    Posted Wed September 13, 2023 08:17 AM

    Hello Team,

    Getting error "Valid base64 passed to dp:decode resulted in non UTF8" in Datapower using XSLT while try to decode base64 encoded string



    ------------------------------
    Jyoti Yadav
    ------------------------------


  • 2.  RE: Getting error "Valid base64 passed to dp:decode resulted in non UTF8" in Datapower

    Posted Tue September 26, 2023 05:23 AM
    Edited by Hermann Stamm-Wilbrandt Tue September 26, 2023 05:24 AM

    Hi,

    XSLT is for processing XML.
    DataPower internal encoding is UTF-8.
    When you do base64 decoding you get that error if the base64 string was not created from a string of UTF-8 encoded XML characters.
    Such strings you cannot process in XSLT, but easily in GatewayScript with Buffer datatype:


    $ echo -ne "foo\x00bar" | base64
    Zm9vAGJhcg==
    $

    In nodejs or GatewayScript:

    > new Buffer('Zm9vAGJhcg==', 'base64')
    <Buffer 66 6f 6f 00 62 61 72>
    >



    ------------------------------
    Hermann Stamm-Wilbrandt
    Compiler Level 3 support
    IBM DataPower Gateways (⬚ᵈᵃᵗᵃ / ⣏⠆⡮⡆⢹⠁⡮⡆⡯⠂⢎⠆⡧⡇⣟⡃⡿⡃)
    https://stamm-wilbrandt.de/en/blog/
    ------------------------------



  • 3.  RE: Getting error "Valid base64 passed to dp:decode resulted in non UTF8" in Datapower

    Posted Tue September 26, 2023 03:09 PM

    Hi Hermann,

    Can this buffer value be utilised in xslt for further decryption?



    ------------------------------
    Nitish Sinha
    ------------------------------



  • 4.  RE: Getting error "Valid base64 passed to dp:decode resulted in non UTF8" in Datapower

    Posted Tue September 26, 2023 06:06 PM
    Edited by Hermann Stamm-Wilbrandt Tue September 26, 2023 06:07 PM

    No, from the XML characters link in my previous posting, these are all possible XML characters:

    [#x7F-#x84], [#x86-#x9F], [#xFDD0-#xFDEF],
    [#x1FFFE-#x1FFFF], [#x2FFFE-#x2FFFF], [#x3FFFE-#x3FFFF],
    [#x4FFFE-#x4FFFF], [#x5FFFE-#x5FFFF], [#x6FFFE-#x6FFFF],
    [#x7FFFE-#x7FFFF], [#x8FFFE-#x8FFFF], [#x9FFFE-#x9FFFF],
    [#xAFFFE-#xAFFFF], [#xBFFFE-#xBFFFF], [#xCFFFE-#xCFFFF],
    [#xDFFFE-#xDFFFF], [#xEFFFE-#xEFFFF], [#xFFFFE-#xFFFFF],
    [#x10FFFE-#x10FFFF].

    No way to have a 0x00 byte inside as in my example.

    If you need to process binary data, since 2015 use GatewayScript for that and not XSLT.



    ------------------------------
    Hermann Stamm-Wilbrandt
    Compiler Level 3 support 
    IBM DataPower Gateways (⬚ᵈᵃᵗᵃ / ⣏⠆⡮⡆⢹⠁⡮⡆⡯⠂⢎⠆⡧⡇⣟⡃⡿⡃)
    https://stamm-wilbrandt.de/en/blog/
    ------------------------------