My goal is to create an unencrypted signed token. I'm generating my JWT like this :
private const string C_ISSUER_SIGNINGKEY = "kXp2s5v8y/B?D(G+KbPeShVmYq3t6w9z";
private const JweAlgorithm JWE_ALGO = JweAlgorithm.DIR;
private const JweEncryption JWE_ENCR = JweEncryption.A128CBC_HS256;
public string GenerateToken(Dictionary<string, object> aPayload, TimeSpan aExpirationTime)
{
var aNowMs = DateTime.Now.ToUniversalTime().Subtract(
new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
).TotalMilliseconds;
if (aExpirationTime.TotalMilliseconds > 0)
{
var lExp = aNowMs + aExpirationTime.TotalMilliseconds;
aPayload.Add("exp", lExp);
}
var aSecretKey = Encoding.UTF8.GetBytes(C_ISSUER_SIGNINGKEY);
var aToken = JWT.Encode(aPayload, aSecretKey, JWE_ALGO, JWE_ENCR);
return aToken;
}
When using this, I get a token like this :
var lPayLoad = new Dictionary<string, object>()
{
{ "emailAddress", "peter@email.com" },
{ "password", "password" }
};
var lToken = lEncryptor.GenerateToken(lPayLoad, new TimeSpan(50,50,50,50));
I'll then get a token like this :eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..4lvBJr_Q0X_hj5OL5rdMsA.d0S--Vdm0JDkjYcN1Djnx4KV3DbehzwkHlvDKlFQuAk.DVS5O8zmJr2l1axenk2Fgw
(Note, that the payload section is empty in the token)
When I try to decode this (via jwt.Io, or any other tool), I can't validate the signer, nor am I able to get the payload.
What on earth am I doing wrong?