【发布时间】:2012-02-10 16:27:34
【问题描述】:
我正在尝试使用 WCF 安全令牌服务网站模板创建一个虚拟安全令牌服务。创建网站时,如果我指定文件系统 URI 并将网站托管在 ASP.NET 开发 Web 服务器中,那么一切似乎都很好。但是,我希望 STS 使用 SSL,并且我还想避免使用 ASP.NET 开发 Web 服务器分配的动态端口时出现的跨域问题。所以我重新创建了同一个网站,但在 IIS 7.5 中为预配置的 Web 应用程序指定了一个 HTTPS URI(例如https://localhost/SecurityTokenService/),而不是文件系统 URI。现在所有导航到 Service.svc 文件的尝试都会导致强制连接重置。
下面是我的 web.config 文件,尽管它在托管在 ASP.NET 开发 Web 服务器中时可以工作,这让我认为问题出在 IIS 设置上。我可能会尝试弄清楚发生了什么事情?
<?xml version="1.0" encoding="UTF-8"?>
<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="ActiveSTS"/>
<add key="SigningCertificateName" value="CN=STSTestCert"/>
<add key="EncryptingCertificateName" value=""/>
</appSettings>
<connectionStrings />
<location path="FederationMetadata">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<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"/>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</controls>
</pages>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
</webServices>
</scripting>
</system.web.extensions>
<system.serviceModel>
<services>
<service name="Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract" behaviorConfiguration="ServiceBehavior">
<endpoint address="https://localhost/SecurityTokenService/Service.svc/IWSTrust13" binding="ws2007HttpBinding" contract="Microsoft.IdentityModel.Protocols.WSTrust.IWSTrust13SyncContract" bindingConfiguration="ws2007HttpBindingConfiguration"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost/SecurityTokenService/Service.svc" />
</baseAddresses>
</host>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<ws2007HttpBinding>
<binding name="ws2007HttpBindingConfiguration">
<security mode="TransportWithMessageCredential">
<message establishSecurityContext="false" clientCredentialType="UserName" />
</security>
</binding>
</ws2007HttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</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="CustomUserNamePasswordTokenHandler, App_Code"/>
</securityTokenHandlers>
</service>
</microsoft.identityModel>
</configuration>
更新:我可以导航到 Web 应用程序中的其他文件。只是不是 *.svc 文件。除了 101 statuc 代码之外,我没有任何可使用的东西,所以这有点令人沮丧。
更新:进一步的实验表明问题仅存在于作为 STS 并托管在 IIS 中的 WCF 服务。如果我在 IIS 中托管常规 WCF 服务,则没有问题。我下载了各种包含自定义 STS 的示例项目,它们都表现出相同的行为。这让我相信我的 IIS 配置有问题,导致它无法与 STS 配合使用。打败我,我怎么可能弄清楚问题是什么......
【问题讨论】: