How to create signature for my JWT?

Viewed 3308

According to JWT (specifically, using the Box.com api), you need to

  1. create your header and claims, base 64 url encode them, join them with a dot.

  2. You then need to take that and the secret key (a little confusion here, more on that in a second) and then encrypt them. For Box.com, it would be using RS256.

  3. You then send that to the provider (again, in this case Box.com) and everything should be fine and dandy.

I have step 1 no problem.

Step 2 is a bit of a problem for me.

  1. I assume I use my ... private key? Edit: Nope, private key is to decrypt.

  2. Although far too many examples exist of doing this with HSA, I need to use RSA and the System.IdentityModel.Tokens.JWT_stuff process has not been very forthcoming with helping. There are a couple other packages and libraries I could use that would be so easy if Box.com allowed for HSA256.

I've taken a look at this question and it hasn't been incredibly helpful.

So what do I need to do to complete step 2? In other words: How can I encrypt using RSA256 in C#?

1 Answers
Related