标签: x509securitytokenmanager

JwtSecurityTokenHandler().ValidateToken()::签名验证失败...在此上下文中不支持sha256

我执行JwtSecurityTokenHandler()时遇到以下错误.ValidateToken()函数:

这是我的伪代码:

var jwtToken = {...}
var tokenHandler = new JwtSecurityTokenHandler();
var validationParameters = new TokenValidationParameters {...};
var claimsPrincipal = tokenHandler.ValidateToken(jwtToken, validationParameters);
Run Code Online (Sandbox Code Playgroud)

这是错误:

Jwt10316: Signature validation failed. Keys tried: 'System.IdentityModel.Tokens.X509AsymmetricSecurityKey'.
Exceptions caught:
 'System.InvalidOperationException: Jwt10518: AsymmetricSecurityKey.GetHashAlgorithmForSignature( 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256' ) threw an exception.
AsymmetricSecurityKey: 'System.IdentityModel.Tokens.X509AsymmetricSecurityKey'
SignatureAlgorithm: 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256', check to make sure the SignatureAlgorithm is supported.
Exception: 'System.NotSupportedException: Crypto algorithm 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256' not supported in this context.
   at System.IdentityModel.Tokens.X509AsymmetricSecurityKey.GetHashAlgorithmForSignature(String algorithm)
   at System.IdentityModel.Tokens.AsymmetricSignatureProvider..ctor(AsymmetricSecurityKey key, String algorithm, Boolean willCreateSignatures)'. 
---> System.NotSupportedException: Crypto algorithm 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256' not supported in …
Run Code Online (Sandbox Code Playgroud)

c# x509securitytokenmanager wif jwt

11
推荐指数
1
解决办法
1万
查看次数

使用以下搜索条件找不到X.509证书:

我收到这条消息:

使用以下搜索条件找不到X.509证书:StoreName'My',StoreLocation'LocalMachine',FindType'FindBySubjectDistinguishedName',FindValue'CN = HighBall'.

我的web.config设置看起来像这样;

身份验证设置如...

<authentication mode="Windows" />
Run Code Online (Sandbox Code Playgroud)

为wsHttpBinging设置绑定

我的服务行为设置如此......

<behavior name="HighBall.Services.ServiceVerificationBehavior">
  <serviceAuthorization principalPermissionMode="UseAspNetRoles"
        roleProviderName="HighBallRoleProvider" />
  <serviceMetadata httpGetEnabled="true" />
  <serviceDebug includeExceptionDetailInFaults="true" />
  <serviceCredentials>
    <serviceCertificate findValue="CN=HighBall" />
    <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
        membershipProviderName="HighBallMembershipProvider" />
  </serviceCredentials>
</behavior>
Run Code Online (Sandbox Code Playgroud)

我试图找出一种方法来验证证书存储的内容,方式和位置,但我不知道如何做到这一点.如果有人对此错误消息有任何想法,我将非常感谢您的帮助.

wcf certificate x509securitytokenmanager x509

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

x509securitytokenmanager ×2

c# ×1

certificate ×1

jwt ×1

wcf ×1

wif ×1

x509 ×1