Error: Requested feature is not implemented - JwtSecurityTokenHandler.WriteToken (RS256) on MAC

Hi,

I am building a MAC application using Xamarin and running into an exception when I try to generate a JWT token using JwtSecurityTokenHandler and JwtSecurityToken. Specifically, I am using JwtSecurityTokenHandler.WriteToken(token) and it fails with following exception:

Exception Details:
IDX10618: AsymmetricSecurityKey.GetHashAlgorithmForSignature( 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256' ) threw an exception.
AsymmetricSecurityKey: 'System.IdentityModel.Tokens.RsaSecurityKey'
SignatureAlgorithm: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256', check to make sure the SignatureAlgorithm is supported.
Exception: 'System.NotImplementedException: The requested feature is not implemented.
at System.IdentityModel.Tokens.RsaSecurityKey.GetHashAlgorithmForSignature (System.String algorithm) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System.IdentityModel/System.IdentityModel.Tokens/RsaSecurityKey.cs:58
at System.IdentityModel.Tokens.AsymmetricSignatureProvider..ctor (System.IdentityModel.Tokens.AsymmetricSecurityKey key, System.String algorithm, Boolean willCreateSignatures) [0x00101] in :0 '.

The same code works fine on windows using Visual Studio 2012 (.NET framework 4.5).

WriteToken MSDN documentation:
https://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.jwtsecuritytokenhandler.writetoken(v=vs.114).aspx

The asymmetric key algorithm used is RSA-SHA256.

Any help is highly appreciated.

Thanks,
Nimish

Sign In or Register to comment.