Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature invalid - failed to validate signature #19

Open
diptenagile opened this issue Mar 31, 2016 · 5 comments
Open

Signature invalid - failed to validate signature #19

diptenagile opened this issue Mar 31, 2016 · 5 comments

Comments

@diptenagile
Copy link

I generated private/public key pair using:

openssl genrsa -out privatekey.pem 1024
openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 1825
openssl pkcs12 -export -out public_privatekey.pfx -inkey privatekey.pem -in publickey.cer

and create private app using publickey.cer file and pass private key in configuration :

var Xero = require('xero');

var CONSUMER_KEY = '...';
var CONSUMER_SECRET = '...';
var RSA_PRIVATE_KEY = require('fs').readFileSync('privatekey.pem');

var xero = new Xero(CONSUMER_KEY, CONSUMER_SECRET, RSA_PRIVATE_KEY);

xero.call('GET', '/Users', null, function(err, json) {
    if (err) {
        console.error(err);
    }
    console.log('response:' + JSON.stringify(json));
});

I also tried to to pass RSA_PRIVATE_KEY directly in xero config.
But still i facing
{ statusCode: 401, data: 'oauth_problem=signature_invalid&oauth_problem_advice=Failed%20to%20validate%20signature' }

Please help me.
Thanks.

@ryardley
Copy link

ryardley commented May 2, 2016

+1

@benbowes
Copy link

benbowes commented May 9, 2016

The below setup is working for me... could it be that you need to use ./privatekey.pem or './cert/privatekey.pem' --- so ./ before your file name ?

var Xero = require('xero');

var CONSUMER_KEY = 'SOME_KEY';
var CONSUMER_SECRET = 'SOME_SECRET';
var RSA_PRIVATE_KEY = require('fs').readFileSync('./cert/privatekey.pem');

var xero = new Xero(CONSUMER_KEY, CONSUMER_SECRET, RSA_PRIVATE_KEY);

xero.call('GET', '/Users', null, function(err, json) {
  if (err) {
    return console.log('Error', err);
  }
  return console.log('json', json);
});

@benbowes
Copy link

benbowes commented Aug 17, 2016

@FreakDroid if I understand your question correctly.

Look into one of these links:

Mac:
https://rietta.com/blog/2012/01/27/openssl-generating-rsa-key-from-command/

PC:
https://support.rackspace.com/how-to/generating-rsa-keys-with-ssh-puttygen/

Also consider the security perspective.

@FreakDroid
Copy link

FreakDroid commented Aug 18, 2016

@benbowes Hi again, thanks for you help.

But now I have another question, after you create the public and private key, How do you upload the publickey in the Xero's server for the autentication??? Because If I understand good, that is necesary for Xero to autenticate you, or I'm complete misunderstand the docs.

Thanks.

@benbowes
Copy link

Hi @FreakDroid

You need to upload your certificate or should I say contents of the certificate.

I placed mine in a folder called cert at the root of the directory and I added the files also to my .gitignore file :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants