WS-Trust - 无法从 WIF、Windows Identity Foundation 接收结果

发布于 2024-10-20 01:08:31 字数 3832 浏览 6 评论 0原文

我创建了带有服务的 Web 应用程序,以使用 WS-Trust 协议为某些 Silverlight 应用程序接收声明。 我看到声明是在 GetOutputClaimsIdentity() 方法中创建的(调用了两次,为什么?),但在 Silverligh 级别上我收到“未找到”消息(空流?)。

Silverlight 对 WS-Trust 的支持是我从最新的 WIF 培训套件中获取的。我试图在服务器端调试代码, 但不幸的是,WIF 源代码尚未作为 .NET Framework 调试的一部分提供:(

所以我不知道为什么它没有正确发送回带有声明的响应给客户端应用程序。WS

-Trust 项目的 Web.config 文件的内容如下(我当前使用自签名证书):

<?xml version="1.0"?>

<configuration>
 <configSections>
 <section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 </configSections>

 <appSettings>
 <add key="IssuerName" value="PatientInfo"/>
 <add key="SigningCertificateName" value="CN=PatientInfo"/>
 <!--<add key="EncryptingCertificateName" value="CN=DefaultApplicationCertificate"/>-->
 <add key="EncryptingCertificateName" value=""/>
 </appSettings>

 <system.web>
 <compilation debug="true" targetFramework="4.0" >
 <assemblies>
 <add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
 </assemblies>
 </compilation>
 <authentication mode="None"/>
 <authorization>
 <allow users="*"/>
 </authorization>
 </system.web>

 <system.serviceModel>

 <serviceHostingEnvironment
 aspNetCompatibilityEnabled="true"
 multipleSiteBindingsEnabled="true" />

 <behaviors>
 <serviceBehaviors>
 <behavior name="ServiceBehavior">
  <serviceMetadata httpGetEnabled="true" />
  <serviceDebug includeExceptionDetailInFaults="true" />
 </behavior>
 </serviceBehaviors>
 </behaviors>
 <bindings>

 <ws2007HttpBinding>
 <binding name="ws2007HttpBindingConfiguration">
  <security mode="TransportWithMessageCredential">
  <message establishSecurityContext="false" clientCredentialType="UserName" />
  </security>
 </binding>
 </ws2007HttpBinding>

 </bindings>

 <services>
 <service name="Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract" behaviorConfiguration="ServiceBehavior">
 <endpoint address="IWSTrust13"
   binding="ws2007HttpBinding"
   bindingConfiguration="ws2007HttpBindingConfiguration"
   contract="Microsoft.IdentityModel.Protocols.WSTrust.IWSTrust13SyncContract"/>
 <host>
  <baseAddresses>
  <add baseAddress="https://WIN-8LUMNJ5E6S4/PatientHistInfo.WS-Trust/InternalAuthentication.svc" />
  </baseAddresses>
 </host>
 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
 </service>
 </services>
 </system.serviceModel>

 <microsoft.identityModel>
 <service>
 <securityTokenHandlers>
 <remove type="Microsoft.IdentityModel.Tokens.WindowsUserNameSecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
 <add type="eSoft.Server.Security.CustomUserNamePasswordTokenHandler, PatientHistInfo.WS-Trust"/>
 </securityTokenHandlers>
 </service>
 </microsoft.identityModel>

 <system.diagnostics>
 <sources>
 <source name="Microsoft.IdentityModel" switchValue="Verbose">
 <listeners>
  <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="WIFTrace.txt" />
 </listeners>
 </source>
 </sources>
 <trace autoflush="true" />
 </system.diagnostics>

</configuration>

Fiddler 结果如下:

HTTP/1.1 504 Fiddler - 接收失败 内容类型:text/html 连接:关闭 时间戳:15:41:21.666

ReadResponse() 失败:服务器未返回此请求的响应。

什么会导致这样的问题?

I created Web App with service to receive claims using WS-Trust protocol for some Silverlight app.
I see claims are created in GetOutputClaimsIdentity() method (called twice-why?), but on Silverligh level I receive 'Not Found' message (empty stream?).

Silverlight support for WS-Trust I took from latest WIF Training kit. I was trying to debug code on server side,
but unfortunately WIF source code is not available as part of .NET Framework debugging yet :(

So I have no idea why it doesn't send back properly the response with claims to client app.

Content of Web.config file for WS-Trust project is below (I use self signed cert currently):

<?xml version="1.0"?>

<configuration>
 <configSections>
 <section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 </configSections>

 <appSettings>
 <add key="IssuerName" value="PatientInfo"/>
 <add key="SigningCertificateName" value="CN=PatientInfo"/>
 <!--<add key="EncryptingCertificateName" value="CN=DefaultApplicationCertificate"/>-->
 <add key="EncryptingCertificateName" value=""/>
 </appSettings>

 <system.web>
 <compilation debug="true" targetFramework="4.0" >
 <assemblies>
 <add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
 </assemblies>
 </compilation>
 <authentication mode="None"/>
 <authorization>
 <allow users="*"/>
 </authorization>
 </system.web>

 <system.serviceModel>

 <serviceHostingEnvironment
 aspNetCompatibilityEnabled="true"
 multipleSiteBindingsEnabled="true" />

 <behaviors>
 <serviceBehaviors>
 <behavior name="ServiceBehavior">
  <serviceMetadata httpGetEnabled="true" />
  <serviceDebug includeExceptionDetailInFaults="true" />
 </behavior>
 </serviceBehaviors>
 </behaviors>
 <bindings>

 <ws2007HttpBinding>
 <binding name="ws2007HttpBindingConfiguration">
  <security mode="TransportWithMessageCredential">
  <message establishSecurityContext="false" clientCredentialType="UserName" />
  </security>
 </binding>
 </ws2007HttpBinding>

 </bindings>

 <services>
 <service name="Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract" behaviorConfiguration="ServiceBehavior">
 <endpoint address="IWSTrust13"
   binding="ws2007HttpBinding"
   bindingConfiguration="ws2007HttpBindingConfiguration"
   contract="Microsoft.IdentityModel.Protocols.WSTrust.IWSTrust13SyncContract"/>
 <host>
  <baseAddresses>
  <add baseAddress="https://WIN-8LUMNJ5E6S4/PatientHistInfo.WS-Trust/InternalAuthentication.svc" />
  </baseAddresses>
 </host>
 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
 </service>
 </services>
 </system.serviceModel>

 <microsoft.identityModel>
 <service>
 <securityTokenHandlers>
 <remove type="Microsoft.IdentityModel.Tokens.WindowsUserNameSecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
 <add type="eSoft.Server.Security.CustomUserNamePasswordTokenHandler, PatientHistInfo.WS-Trust"/>
 </securityTokenHandlers>
 </service>
 </microsoft.identityModel>

 <system.diagnostics>
 <sources>
 <source name="Microsoft.IdentityModel" switchValue="Verbose">
 <listeners>
  <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="WIFTrace.txt" />
 </listeners>
 </source>
 </sources>
 <trace autoflush="true" />
 </system.diagnostics>

</configuration>

Fiddler result is below:

HTTP/1.1 504 Fiddler - Receive Failure
Content-Type: text/html
Connection: close
Timestamp: 15:41:21.666

ReadResponse() failed: The server did not return a response for this request.

What can cause such issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文