DataPower

 View Only
  • 1.  Encryption using the cert from JSON body

    Posted Wed April 01, 2020 01:26 PM
    Do we have any methods to encrypt the payload using the certificate which is coming in the JSON payload or Header etc.

    1. XSLT via dp extension function?
    2.Gateway Scripts ?.

    is this possible ?.

    i have looked at "node-forge". I couldn't contemplate how we can use this kind of scripts in datapower

    ------------------------------
    santhosh
    ------------------------------


  • 2.  RE: Encryption using the cert from JSON body

    Posted Wed April 01, 2020 04:21 PM

    https://www.npmjs.com/package/node-forge
    "Forge uses a CommonJS module structure with a build process for browser bundles."

    https://www.ibm.com/support/knowledgecenter/SS9H2Y_7.7.0/com.ibm.dp.doc/gatewayscript_model.html

    Gateway script includes ECMAScript, CommonJS, and DataPower-specific GatewayScript APIs.

    You should be able to use Forge with GatewayScript because of CommonJS.



    ------------------------------
    Hermann Stamm-Wilbrandt
    Compiler Level 3 support & Fixpack team lead
    IBM DataPower Gateways (⬚ᵈᵃᵗᵃ / ⣏⠆⡮⡆⢹⠁⡮⡆⡯⠂⢎⠆⡧⡇⣟⡃⡿⡃)
    ------------------------------



  • 3.  RE: Encryption using the cert from JSON body

    Posted Tue April 07, 2020 02:06 PM
    Hi Hermann

    I have upload the forge files(https://github.com/digitalbazaar/forge/tree/master/lib) into dp and it seems some of the codes meant for browser . Any idea how to address this errors?.

    ****My js code as below
    var service = require('service-metadata');
    var pki = require('pki');
    service.mpgw.skipBackside = true;
    var pem = '#######';
    var cert = pki.certificateFromPem(pem);
    console.log(cert.validity.notAfter);
    ****
    Note : Removed my cert details from var and placed as ###


    Below are the errors :
    GatewayScript processing Error 'ReferenceError: window is not defined In file 'local:///util.js' line:123, stack:ReferenceError: window is not defined at local:///util.js:123:40 at Object.<anonymous> (local:///util.js:124:3) at ModuleContext.require (gatewayscript:///datapower.js:406:33) at Object.<anonymous> (local:///asn1.js:137:1) at ModuleContext.require (gatewayscript:///datapower.js:406:33) at Object.<anonymous> (local:///pki.js:10:1) at ModuleContext.require (gatewayscript:///datapower.js:406:33) at Object.<anonymous> (local:///commonnameverify.js:11:11) at Script.execute (gatewayscript:///datapower.js:155:24) at Object.<anonymous> (gatewayscript:///datapower.js:582:55)'


    ------------------------------
    santhosh
    ------------------------------



  • 4.  RE: Encryption using the cert from JSON body

    Posted Wed April 08, 2020 05:50 AM
    Edited by Hermann Stamm-Wilbrandt Wed April 08, 2020 05:51 AM

    Hi,
    you have to replace code based on undefined window.
    Only function using window in util.js is "util.getQueryVariables":

    https://github.com/digitalbazaar/forge/blob/master/lib/util.js#L2340

    Just reimplement that function making use of GatewayScript querystring module:

    https://www.ibm.com/support/knowledgecenter/SS9H2Y_7.7.0/com.ibm.dp.doc/querystring_js.html



    ------------------------------
    Hermann Stamm-Wilbrandt
    Compiler Level 3 support & Fixpack team lead
    IBM DataPower Gateways (⬚ᵈᵃᵗᵃ / ⣏⠆⡮⡆⢹⠁⡮⡆⡯⠂⢎⠆⡧⡇⣟⡃⡿⡃)
    ------------------------------



  • 5.  RE: Encryption using the cert from JSON body

    Posted Wed March 20, 2024 02:59 PM

    Hi Hermann,

    I need to use Forge library in IBM Datapower, but i dont know how to "Just reimplement that function making use of GatewayScript querystring module:", can you explain more details 

    I want to create the signature using PKCS#7 (CMS). 

    Thank you very much



    ------------------------------
    Quoc Tuan
    ------------------------------



  • 6.  RE: Encryption using the cert from JSON body

    Posted Wed March 20, 2024 06:51 PM

    util.js changed in the past 4 years, no match to what was discussed before.

    Do you get an error when using it?



    ------------------------------
    Hermann Stamm-Wilbrandt
    Compiler Level 3 support, IBM DataPower Gateways
    IBM
    Boeblingen Germany
    ------------------------------