Cybersource jwt token using p12 file

I am trying to create a postman collection for the cybersource APIs. They support 2 authentication schemes. the first is a shared secret http signature model and the second involves creating a jwt token generation using a .p12 certification file.

I was able to use pre-request scripting to get the http signature authentication to work but I’m having trouble with the jwt authentication.

How can I read in the p12 file so that I can create the jwt token?

for reference, here is the example node.js code from cybersource.


I got this to work…sort of…I wasn’t able to read the p12 file directly but through a lot of searches I was able to figure out how to extract the public/private keys from the P12 file via OpenSSL and store them in an environment variable. I then used those environment variables along with importing jsrsasign-js through another environment variable to do the necessary RS256 signing of the jwt header.