I struggled and messed around for about two days to create the digital signature for the specific API calls mentioned at:
https://developer.ebay.com/develop/guides/digital-signatures-for-apis
As the documentation – especially for C# – is pretty poor, particularly for this critical change in calling the Restful APIs, I want to share my finally working solution.
Overall, my question was to create all the headers and the signed signature base.
Already using the ‘OAuth scope’ with access token created with the client credentials grant flow, creating the signing keys by the ‘Key Management API’ was not a big deal.
My first problem was Error 215114 saying ‘The create time of signature parameters is not in right range’, as I thought I need to use the creation time of the created signing keys. But you need to use the time of the call.
I first created the signing keys with RSA-SHA256 cipher, but as I struggled to sign the signature base and eBay recommends Ed25519 cipher, I gave Ed25519 a try and created new keys with it.
Nevertheless I struggled with signing the signature base for the ‘Signature’-header, received 215002 error (‘Internal errors as fetching master key’) in the meantime, and after all ended with error 215120 resp. 215122 ‘Signature validation failed’.
I’m using .NET 6 and RestSharp for the actual API call, tried the ‘RSA Class’ from System.Security.Cryptography, but now use BouncyCastle for signing in my working solution.
2
Answers
So, this is my working solution with successful response, using RestSharp and BouncyCastle, with given eBay access token and Ed25519-signing keys.
The keys are not in PEM format, like so:
JWE:
eyJ6aXAiOiJERUYiLCJraWQiOiJiNmI4ZW[...]
Private Key:
MC4CAQAwBQYDK2VwBCIEIDIpPLbihtModG[...]
Public Key:
MCowBQYDK2VwAyEA0CjbDt2NDS7LKbQS6i[...]
I think I solved my problem with successfully signing the base by noting it with "-----BEGIN ... KEY-----" and "-----END ... KEY-----" and create the key parameters with PemReader.
For the decoding of the keys from the response, it appears that you could decode the private key like this:
Similarly the public key: