We're doing an integration with Google via RESTful API and I need to sign a payload of a JWT with RSA-SHA256 and all I have is a Private Key as a string, that looks like
-----BEGIN PRIVATE KEY-----
MIIEvgIBfADANBg9qhkdsiG9w0BAQEFAASCBKgw
......
-----END PRIVATE KEY-----
I've been looking everywhere for a solution, but everyone's talking about X509Certificate2
which needs a p12 file, or some Certificates. Now I don't have either of those, I only have a string that is the private key.
Google recommends https://jwt.io/ and it works with the key string, but well, I need my CODE to do it. There are 3 libraries listed in the page:
- One of them belongs to Microsoft and has absolutely no documentation.
- Another one is using
X509Certificate2
or specifically for string keys only has a link to this place http://www.donaldsbaconbytes.com/2016/08/create-jwt-with-a-private-rsa-key/ which uses some Certificate files I don't have, making it a wrong and unhelpful link to begin with. - Same creators of #2 have another lib, but it's for phones and it actually has a method for RSA256 signing which takes private key as a string of exactly my format.
So my question is - is there some working solution for my case? Because I can't believe that no one else has integrations with Google.