1

I am using KARATE with the standalone JAR, version 0.9.5.RC5. Inside a Karate scenario, I have to sign a string with a private key, using the SHA256 with ECDSA algorithm, in base64. I need this signature further in a request. So, I have written in the scenario :

* def stringtobesigned = 'mystringtosign'
* def privkey = 'DeIHYzu9...'
* def Signature = call read('sha256ECDSA.js')

And in the sha256ECDSA.js file, I have written :

function fn() {
    var mykey = karate.get('privkey');
    var strToBeSigned = karate.get('idstring2signed');
    ...
    return signValue;
    }

Can anybody tell me how to implement this algorithm in my use case? I need to replace '...' with the right code, to the value 'signValue'. Thanks a lot.

Vendetta
  • 2,078
  • 3
  • 13
  • 31
J-Marc
  • 29
  • 3
  • this is not really a karate question and is simply "how to do this in Java" and then you plug in as you already know how to do. so refer this: https://stackoverflow.com/q/25261823/143475 – Peter Thomas Feb 03 '20 at 17:14
  • In my sha256ECDSA.js file, I want to use the jsrsasign javascript Library (wich provides the SHA256 with ECDSA encryption), with this first line : var r = require('jsrsasign'); But it doesn't work because require uses Node.js. So, how to do that ? Thanks ! – J-Marc Feb 04 '20 at 16:48
  • you can't: https://stackoverflow.com/a/52100077/143475 – Peter Thomas Feb 04 '20 at 17:14
  • Ok… you have written : "My suggestion is you should find a Java library that does what "faker" does and integrate it.". Is it possible with the Karate standalone JAR too ? – J-Marc Feb 05 '20 at 08:23
  • yes: https://stackoverflow.com/a/56458094/143475 – Peter Thomas Feb 05 '20 at 08:46

0 Answers0