vonage-dotnet-sdk icon indicating copy to clipboard operation
vonage-dotnet-sdk copied to clipboard

PemParse is now inaccessible as per v5.10.0

Open emmaduttonaccurx opened this issue 2 years ago • 0 comments

Describe the bug PemParse.DecodePEMKey() was working in v5.9.5 but since upgrading to v5.10.0 this is now inaccessible and has been made internal: https://github.com/Vonage/vonage-dotnet-sdk/commit/5b6b2523e522742640cd5a1a4ca4d59aa4b2a151

We're using this to create a JWT with custom arguments as Jwt.cs doesn't support this.

To Reproduce

var tokenData = new byte[64];
var rng = RandomNumberGenerator.Create();
rng.GetBytes(tokenData);
var jwtTokenId = Convert.ToBase64String(tokenData);

var payload = new Dictionary<string, object>
{
    { "iat", (long) (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds },
    { "exp", (long) (DateTime.UtcNow.AddDays(1) - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds },
    { "application_id", appId },
    { "jti", jwtTokenId },
    { "sub", username },
    {"acl", new Dictionary<string, object>
    {
            {"paths", new Dictionary<string, object>
            {
                    {"/*/users/**", new object()},
                    {"/*/conversations/**", new object()},
                    {"/*/sessions/**", new object()},
                    {"/*/devices/**", new object()},
                    {"/*/image/**", new object()},
                    {"/*/media/**", new object()},
                    {"/*/applications/**", new object()},
                    {"/*/push/**", new object()},
                    {"/*/knocking/**", new object()},
                    {"/*/legs/**", new object()},
                }}
        }}
};


var rsa = PemParse.DecodePEMKey(privateKey);
return JWT.Encode(payload, rsa, JwsAlgorithm.RS256);

Expected behavior Expect to use DecodePEMKey() to create a JWT.

Additional context Is there a new way to make a JWT with custom arguments?

emmaduttonaccurx avatar Jul 07 '22 14:07 emmaduttonaccurx