[CryptoAPI] Sign data SHA256 and output with private key base64

Forge Component
Published on 3 Mar by Ricardo Silva
26 votes
Published on 3 Mar by Ricardo Silva

Hi guys,

So I'm really a noob on this but hopefully some one can help me out a bit.

I need to build the next part from javascript into Outsystems:

const dataToSign = Object.values(paramsOrdered).join(';');
const sign = crypto.createSign('SHA256');
return sign.sign(privateKey, 'base64');

So we have paramsOrdered that says: par1=x, par2=y, par3=z.

The data to sign results in par1=x;par2=y;par3=z

Then we need to sign this with SHA256 for this I will use: computeHash with SHA256

So but then I need to sign it with the private key and the output should be base64.

Does this mean use: RSA_SIGN and then convert the output of this to base64?

I'm now doing first a computeHash with SHA256 on the paramsOrdered.

Then I use the RSA_PrivateKeyFromPEM to convert my private key to a usable private key.

After that I use the RSA_Sign to sign the base64 output of the computehas with the output of the privatekey from RSA_PrivateKeyFromPEM.

Then I do a TextToBinaryData on the output of the RSA_Sign.

The binary output I use to call the soap service.

Only the soap service is now giving a error: "Data doesn't match signature"