Hi ,
we have a requirement to develop a script to validate the signature on the header using a public key.
var apim = require('apim');
var Signature = apim.getvariable('message.Signing Header');
// Beginning public key
const l1 = "-----BEGIN PUBLIC KEY-----\n"
// Encrypted data
const l2 =
"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEXIvPbzLjaPLd8jgiv1TL/X8PXpJNgDkGRj9U9Lcx1yKURpQFVavcMkfWyO8r7JlZNMax0JKfLZUM1IePRjHlFw=="
// Ending public key
const l3 = "\n-----END PUBLIC KEY-----"
// Constructing public key
const publicKey = l1 + l2 + l3
if ((verify.verify(publicKey, signature))=== false)
{
apim.error('Unauthorized', XXX, 'Unauthorized','Signature validation failed');
}
})
}
}
In stead of making public key hardcoded in script want to read the content of the certificate . Anybody can suggest how to read the certificate and its content content as hardcoded in the code.
------------------------------
Debasis Samal
------------------------------