我试图解决这个问题一段时间,但没有运气,也许有更多 Sharepoint 经验的人能够找出我的问题。

Sharepoint 日志中的异常堆栈跟踪如下所示:

System.IdentityModel.Tokens.SecurityTokenException: The issuer of the token is not a trusted issuer.    
at Microsoft.SharePoint.IdentityModel.SPLocalIssuerNameRegistry.GetIssuerName(SecurityToken securityToken)     
at Microsoft.IdentityModel.Tokens.Saml11.Saml11SecurityTokenHandler.CreateClaims(SamlSecurityToken samlSecurityToken)     
at Microsoft.IdentityModel.Tokens.Saml11.Saml11SecurityTokenHandler.ValidateToken(SecurityToken token)     
at Microsoft.IdentityModel.Tokens.SecurityTokenHandlerCollection.ValidateToken(SecurityToken token)     
at Microsoft.IdentityModel.Web.TokenReceiver.AuthenticateToken(SecurityToken token, Boolean ensureBearerToken, String endpointUri)     
at Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequest request)     
at Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args)     
at Microsoft.SharePoint.IdentityModel.SPFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs eventArgs)     
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

我查看了反编译后的代码,如下所示:

 if (!accessProvider.SigningCertificate.Equals((X509Certificate) x509SecurityToken.Certificate))
    throw new SecurityTokenException(SPResource.GetString("IssuerIsNotTrusted"));

因此,看起来收到的安全令牌和访问提供商证书不匹配。我更进一步,进行故障转储,加载到 Windbg 中,并尝试查找具有 accessProvider 的证书,不确定我是否在正确的位置搜索,但如果是,那么它的证书错误 - 它的主题是 CN=SharePoint Security Token Service, OU=SharePoint, O=Microsoft, C=US, ,显然不是我配置的。

我正在像这样注册我的身份提供商:

$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\temp\wcfsts.dev.cer")
$map1 = New-SPClaimTypeMapping -IncomingClaimType "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" -IncomingClaimTypeDisplayName "Display Name" –SameAsIncoming
$realm = "http://sp2013.testweb.local"
$ap = New-SPTrustedIdentityTokenIssuer -Name "WSFederationSTS" -Description "WCF STS." –Realm $realm -ClaimsMappings $map1 -ImportTrustCertificate $cert -SignInUrl "http://wcfsts.dev/WSFederationSecurityTokenService.svc/Issue" -IdentifierClaim $map1.InputClaimType

我还注册了证书 New-SPTrustedRootAuthority.

有帮助吗?

解决方案

我无意中发现了这个问题,通过查看我可能做错了什么。
我正在寻找 索赔演练 并注意到,他们使用 C# 代码注册令牌发行者,因此决定做同样的事情,他们使用提供者领域”https://intranet.contoso.com/_trust/”,所以我只是将其更改为拥有我的域,同时保留“_trust”部分 - 它开始工作,因此日志中的异常非常具有误导性。

这之后我发现 博客文章 遇到同样的问题,想知道为什么我之前没有注意到它。

其他提示

我按照此链接中的一些说明进行操作:https://support.microsoft.com/en-us/help/3042604/the-convert-spwebapplication-command-cannot-convert-from-windows-claim

它对 New-SPTrustedIdentityTokenIssuer 命令使用以下格式:

$ap = New-SPTrustedIdentityTokenIssuer -Name $tokenIdentityProviderName -Description $TrustedIdentityTokenIssuerDescription -realm $siteRealm -ImportTrustCertificate $adfsCert -SignInUrl $signInUrl -UseDefaultConfiguration -IdentifierClaimIs EMAIL -RegisteredIssuerName $siteRealm

我不确定要为 RegisteredIssuerName 添加什么内容,并且之前在其工作时将其留空,但在本例中,我将其设置为与 $tokenIdentityProviderName 相同。

此后我开始收到“令牌的发行者不是受信任的发行者”错误。

我清除了 RegisteredIssuerName 的值:

Set-SPTrustedIdentityTokenIssuer -Identity $ap  -RegisteredIssuerName ""

这为我解决了这个问题。

我相信要使 RegisteredIssuerName 正常工作,您可能需要向 web.config 添加一个 IssuerNameRegistry 条目以指定受信任的令牌颁发者。

<issuerNameRegistry 
  type="Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry,
  Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35">
  <trustedIssuers>
      <add thumbprint="99fcfe2c70ebb571020ca8aa1b7633dfe1fa1d58" name="http://localhost:48924/WingtipSTS/" />
  </trustedIssuers>
</issuerNameRegistry>

附加来源:https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ff955607(v=office.14)

许可以下: CC-BY-SA归因
scroll top