Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

Random "Keyset does not exist" errors

Started by Peter Olle -   in Wrapper libraries


We are using the https://github.com/XeroAPI/Xero-Net wrapper library to push invoices from our .Net web app into a clients Xero instance (UK based).

We use "PrivateAuthenticator" to manage our connection.

We are seeing the following error being thrown (including stack)..

Error processing invoice 123880: Keyset does not exist
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()
at Xero.Api.Infrastructure.ThirdParty.Dust.RsaSha1.Sign(SHA1CryptoServiceProvider hash)
at Xero.Api.Infrastructure.ThirdParty.Dust.RsaSha1.SignCore(String baseString)
at Xero.Api.Infrastructure.OAuth.Signing.RsaSha1Signer.CreateSignature(X509Certificate2 certificate, IToken token, Uri uri, String verb, String verifier, Boolean renewToken, String callback)
at Xero.Api.Example.Applications.Private.PrivateAuthenticator.GetSignature(IConsumer consumer, IUser user, Uri uri, String verb, IConsumer consumer1)
at Xero.Api.Infrastructure.Http.HttpClient.CreateRequest(String endPoint, String method, String accept, String query)
at Xero.Api.Infrastructure.Http.HttpClient.Get(String endpoint, String query)
at Xero.Api.Infrastructure.Http.XeroHttpClient.Get[TResult,TResponse](String endPoint)
at Xero.Api.Common.XeroReadEndpoint`3.Get(String endpoint, String child)
at Xero.Api.Common.XeroReadEndpoint`3.Find()
at ipCloudLib.Export.ipXero.XeroCustomer.GetUid() in \ipCloudLib\Export\Xero\XeroCustomer.vb:line 83

Now one problem is that this does not happen all of the time. Some invoices actually get through??? We have strengthened or error capturing routines in an attempt to get more detail but with no joy.

It looks like a certificate problem but as I said, sometimes it works. Does anyone have any tips on how to track down this issue?


I am also facing the same issues. Did you find any solution on this ? The library suddenly throws the Keyset error after a few calls.

Integration Support at VNC  

Nope not a thing. As you can see, not much in the way of support from Xero. I moved to using CSV exports until this is sorted. I am thinking moving to OAuth 2.0 may help?

Peter Olle  

Just to update you, I had the api called in async manner because of wich all of them were called at once. On changing the call to sync I did not get the error. And ya OAuth2 should be the way.

Integration Support at VNC  

Ahh thanks for the tip on sync

Peter Olle