You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm using this library to generate auth headers for Jira. Jira uses RSA-SHA1 to verify tokens so I have to modify the hash_function used in the examples. I was running into an issue where the key being passed into the function has been escaped causing an error when using it to sign.
Here is the initialization of OAuth I have, with console logs to demonstrate the issue,
constoauth=OAuth({consumer: {key: OAUTH_CONSUMER_KEY,secret: privateKey},signature_method: "RSA-SHA1",hash_function(base_string,key){console.log("Private key from global scope \n");console.log(privateKey);console.log("Private key from function scope \n");console.log(key);constsign=crypto.createSign("RSA-SHA1");sign.update(base_string);sign.end();constsignature=sign.sign(privateKey).toString("base64");returnsignature;},});
Which, when a header is generated, leads to an output of,
Private key from global scope
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V
A7qVvdqxevEuUkW4K+2KdMXmnQbG9Aa7k7eBjK1S+0LYmVjPKlJGNXHDGuy5Fw/d
7rjVJ0BLB+ubPK8iA/Tw3hLQgXMRRGRXXCn8ikfuQfjUS1uZSatdLB81mydBETlJ
hI6GH4twrbDJCR2Bwy/XWXgqgGRzAgMBAAECgYBYWVtleUzavkbrPjy0T5FMou8H
X9u2AC2ry8vD/l7cqedtwMPp9k7TubgNFo+NGvKsl2ynyprOZR1xjQ7WgrgVB+mm
uScOM/5HVceFuGRDhYTCObE+y1kxRloNYXnx3ei1zbeYLPCHdhxRYW7T0qcynNmw
rn05/KO2RLjgQNalsQJBANeA3Q4Nugqy4QBUCEC09SqylT2K9FrrItqL2QKc9v0Z
zO2uwllCbg0dwpVuYPYXYvikNHHg+aCWF+VXsb9rpPsCQQDWR9TT4ORdzoj+Nccn
qkMsDmzt0EfNaAOwHOmVJ2RVBspPcxt5iN4HI7HNeG6U5YsFBb+/GZbgfBT3kpNG
WPTpAkBI+gFhjfJvRw38n3g/+UeAkwMI2TJQS4n8+hid0uus3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6O6NLQxISLKcPDk2NOccAfS%2FxOtfOz4sJYM3%2BBs4Io9%2BdZGSDCA54%0ALw03eHTNQghS0A%3D%3D%0A-----END%20PRIVATE%20KEY-----
The private key from the function scope has been escaped as well as duplicated, which causes the signing to fail.
Using the key from global scope works fine.
Also, don't worry, this private key is irrelevant, its the one generated by Atlassian in their example project.
Any ideas or suggestions as to what could be happening would be appreciated.
Thanks
Update:
I've tracked it down to this method in the library,
Hello,
I'm using this library to generate auth headers for Jira. Jira uses RSA-SHA1 to verify tokens so I have to modify the hash_function used in the examples. I was running into an issue where the key being passed into the function has been escaped causing an error when using it to sign.
Here is the initialization of OAuth I have, with console logs to demonstrate the issue,
Which, when a header is generated, leads to an output of,
The private key from the function scope has been escaped as well as duplicated, which causes the signing to fail.
Using the key from global scope works fine.
Also, don't worry, this private key is irrelevant, its the one generated by Atlassian in their example project.
Any ideas or suggestions as to what could be happening would be appreciated.
Thanks
Update:
I've tracked it down to this method in the library,
The text was updated successfully, but these errors were encountered: