WsFederation OWIN +序列不包含任何元素错误

时间:2018-09-25 16:35:37

标签: asp.net-mvc identityserver4 ws-federation

我正在尝试使用.NET 4.6应用程序设置Google App Suites身份验证。

我正在使用Microsoft.Owin.Security.WsFederation OWIN nuget包,这是我在启动时使用的代码:

app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
{
    MetadataAddress = "URL TO HOSTED META DATA XML",
    Wtrealm = "blah", 
    TokenValidationParameters = new TokenValidationParameters
    {
        ValidateAudience = false,
        ValidAudiences = new List<string>()
        {
            wtrealm,
            validAudience
        }
    },
    SignInAsAuthenticationType = "Cookies"
});

我一直收到错误消息“ InvalidOperationException:序列不包含任何元素”。我怀疑元数据文件有问题,但我不确定是什么(我从Google App Suites Admin获得了此文件)。由于WSFed需要URL,因此我在.NET应用程序中托管此元数据文件。知道我在这里做错了什么吗?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="https://accounts.google.com/o/saml2?idpid=C03tzverc" validUntil="2023-08-06T13:59:09.000Z">
  <md:IDPSSODescriptor WantAuthnRequestsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
    <md:KeyDescriptor use="signing">
      <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:X509Data>
          <ds:X509Certificate>MIIDdDCCA...REMOVED THE REST</ds:X509Certificate>
        </ds:X509Data>
      </ds:KeyInfo>
    </md:KeyDescriptor>
    <md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</md:NameIDFormat>
    <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://accounts.google.com/o/saml2/idp?idpid=C03tzverc"/>
    <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://accounts.google.com/o/saml2/idp?idpid=C03tzverc"/>
  </md:IDPSSODescriptor>
</md:EntityDescriptor>

这是完整的堆栈:

[InvalidOperationException:序列不包含任何元素]    System.Linq.Enumerable.First(IEnumerable`1源)+264    c:\ workspace \ WilsonForDotNet45Release \ src \ Microsoft.IdentityModel.Protocol.Extensions \ Configuration \ WsFederationConfigurationRetriever.cs:100中的Microsoft.IdentityModel.Protocols.d__1.MoveNext()    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务任务)+25    c:\ workspace \ WilsonForDotNet45Release \ src \ Microsoft.IdentityModel.Protocol.Extensions \ Configuration \ ConfigurationManager.cs:198

中的Microsoft.IdentityModel.Protocols.d__3.MoveNext()

[InvalidOperationException:IDX10803:无法创建以从以下位置获取配置:“针对安全原因已删除”。]    c:\ workspace \ WilsonForDotNet45Release \ src \ Microsoft.IdentityModel.Protocol.Extensions \ Configuration \ ConfigurationManager.cs:212中的Microsoft.IdentityModel.Protocols.d__3.MoveNext()    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    Microsoft.Owin.Security.WsFederation.d__c.MoveNext()+432    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    Microsoft.Owin.Security.Infrastructure.d__b.MoveNext()+282    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    Microsoft.Owin.Security.Infrastructure.d__8.MoveNext()+275    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    Microsoft.Owin.Security.Infrastructure.d__5.MoveNext()+160    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    Microsoft.Owin.Security.Infrastructure.d__0.MoveNext()+815    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext()+182    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    Microsoft.Owin.Security.Infrastructure.d__0.MoveNext()+638    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext()+182    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)+99    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)+58    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__2.MoveNext()+180    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)+69    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)+64    System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+380    System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep步骤)+48    System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值并已完成同步)+159

0 个答案:

没有答案