Generate RSA-SHA1 signature based off of a string and private key

SanjivMeher
Kilo Patron
Kilo Patron

I am working on a JIRA integration from Servicenow and the authentication I want to use is oAuth 1.0. As servicenow doesnt support oAuth 1.0, I am writing custom code to make it work.

I have the access token, consumer id etc, and I am trying to generate a signature, with a private key and a string I have.

Is there a function which can generate the signature using RSA-SHA1 algorithm?

I know I can generate the HMAC SHA1, but RSA-SHA1 is not supported

 

var mac = new CertificateEncryption();
var signature = mac.generateMac(pkey, "RSA-SHA1", signatureBaseString);


Please mark this response as correct or helpful if it assisted you with your question.
1 ACCEPTED SOLUTION

Yes. I had a certificate which was in pkcs8 format. I converted it to pkcs12 format and loaded it in sys_certificate table. Once you do that, use below function, which will generate the signature.

var ce = new CertificateEncryption();
ce.sign("sysid of the certificate", "1", "", "SHA1withRSA", "datastring");

Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

12 REPLIES 12

SanjivMeher
Kilo Patron
Kilo Patron

Anyone?


Please mark this response as correct or helpful if it assisted you with your question.

Rahman4
Tera Guru

Hey mate,

Did you manage to find out a solution for your problem? Appreciate any feedback.

I have a similar problem and would love to hear from you.

 

TIA

Yes. I had a certificate which was in pkcs8 format. I converted it to pkcs12 format and loaded it in sys_certificate table. Once you do that, use below function, which will generate the signature.

var ce = new CertificateEncryption();
ce.sign("sysid of the certificate", "1", "", "SHA1withRSA", "datastring");

Please mark this response as correct or helpful if it assisted you with your question.

This is exactly what I'm looking for! Thanks for providing. The only issue I'm seeing is an error in the logs... "CertificateEncryption" is not defined. 

I tried with and without the () at the end of CertificateEncryption.

var ce = new CertificateEncryption();
ce.sign("8cb02fa5db971850a80f5716f496197f", "", "password", "SHA1withRSA", "sign this data");

var ce = new CertificateEncryption;
ce.sign("8cb02fa5db971850a80f5716f496197f", "", "password", "SHA1withRSA", "sign this data");

How does one use this in the Global Scope?