2017-03-21 55 views
1

以下代碼是在Windows中使用VS編寫的,它似乎在Windows中運行良好。在Monodevelop中編寫JSON Web令牌時出現異常IDX10632

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. 

我還沒有發現太多的谷歌或StackOverflow的這一點,並沒有想到別的不多我可以嘗試。它是否依賴於某些需要安裝的外部資源或軟件包?我確定安裝了OpenSSL。

This似乎是相關的,但我沒有使用卡塔納或OpenID,這不是一個問題與對稱與不對稱。

回答