在 Monodevelop 中写入 JSON 网络令牌时出现异常 IDX10632
Exception IDX10632 on writing JSON web token in Monodevelop
以下代码是在 Windows 中使用 VS 编写的,它似乎 运行 在 Windows 中很好。
List<Claim> claimsList;
InMemorySymmetricSecurityKey key;
// fill claims and key with data
var token = new JwtSecurityToken
(
claims: claimsList,
signingCredentials: new SigningCredentials(key, SecurityAlgorithms.HmacSha256Signature, SecurityAlgorithms.Sha256Digest)
);
var tokenHandler = new JwtSecurityTokenHandler();
string tokenStr = tokenHandler.WriteToken(token);
在 Ubuntu 中对 MonoDevelop 进行测试时,它在 tokenHandler.WriteToken(token)
上失败并显示以下消息:
System.InvalidOperationException : IDX10632: SymmetricSecurityKey.GetKeyedHashAlgorithm( 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256' ) threw an exception.
SymmetricSecurityKey: 'System.IdentityModel.Tokens.InMemorySymmetricSecurityKey'
SignatureAlgorithm: 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256', check to make sure the SignatureAlgorithm is supported.
Exception: 'System.NotSupportedException: Specified method is not supported.
at System.IdentityModel.Tokens.InMemorySymmetricSecurityKey.GetKeyedHashAlgorithm (System.String algorithm) <0x40200b40 + 0x0008b> in <filename unknown>:0
at System.IdentityModel.Tokens.SymmetricSignatureProvider..ctor (System.IdentityModel.Tokens.SymmetricSecurityKey key, System.String algorithm) <0x40200350 + 0x000c7> in <filename unknown>:0 '.
----> System.NotSupportedException : Specified method is not supported.
我在 Google 或 Whosebug 上没有找到太多关于此的信息,也没有想到我可以尝试的其他内容。它是否依赖于一些需要安装的外部资源或包?我已确保安装了 OpenSSL。
This 似乎是相关的,但我没有使用 Katana 或 OpenID,这不是对称与非对称的问题。
这个appears to be a bug/deficiency in Mono。早在2015年就有报道,可惜截至目前(2017年9月),仍未修复。
以下代码是在 Windows 中使用 VS 编写的,它似乎 运行 在 Windows 中很好。
List<Claim> claimsList;
InMemorySymmetricSecurityKey key;
// fill claims and key with data
var token = new JwtSecurityToken
(
claims: claimsList,
signingCredentials: new SigningCredentials(key, SecurityAlgorithms.HmacSha256Signature, SecurityAlgorithms.Sha256Digest)
);
var tokenHandler = new JwtSecurityTokenHandler();
string tokenStr = tokenHandler.WriteToken(token);
在 Ubuntu 中对 MonoDevelop 进行测试时,它在 tokenHandler.WriteToken(token)
上失败并显示以下消息:
System.InvalidOperationException : IDX10632: SymmetricSecurityKey.GetKeyedHashAlgorithm( 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256' ) threw an exception.
SymmetricSecurityKey: 'System.IdentityModel.Tokens.InMemorySymmetricSecurityKey'
SignatureAlgorithm: 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256', check to make sure the SignatureAlgorithm is supported.
Exception: 'System.NotSupportedException: Specified method is not supported.
at System.IdentityModel.Tokens.InMemorySymmetricSecurityKey.GetKeyedHashAlgorithm (System.String algorithm) <0x40200b40 + 0x0008b> in <filename unknown>:0
at System.IdentityModel.Tokens.SymmetricSignatureProvider..ctor (System.IdentityModel.Tokens.SymmetricSecurityKey key, System.String algorithm) <0x40200350 + 0x000c7> in <filename unknown>:0 '.
----> System.NotSupportedException : Specified method is not supported.
我在 Google 或 Whosebug 上没有找到太多关于此的信息,也没有想到我可以尝试的其他内容。它是否依赖于一些需要安装的外部资源或包?我已确保安装了 OpenSSL。
This 似乎是相关的,但我没有使用 Katana 或 OpenID,这不是对称与非对称的问题。
这个appears to be a bug/deficiency in Mono。早在2015年就有报道,可惜截至目前(2017年9月),仍未修复。