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

Quick question. Your instructions says copy content from 'jirapublickey.pem' exactly below jirapriatekey_copy.pem file. 

the example show, as 

-----BEGIN CERTIFICATE-----

<Public Key>

-----END CERTIFICATE-----

 

is that jirapublickey.cer file or jirapublickey.pem file? .pem will have 

-----BEGIN PUBLIC KEY-----

-----END PUBLIC KEY-----

 

is that a .cert or .pem should we use for PUBLIC KEY?

It should be the .pem file in the public key.

But I dont exactly remember, because I have done this long time back.

Try with .pem and if that doesnt work, you will have to try with .cert


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

Saif7
Tera Contributor

Hello Sanjov!

Thanks for sharnig this information with us,

I have a question here, your post meaning that we can use OAuth 1 in ServiceNow! Please confirm because  thats very important to me!

Best Regards.