【发布时间】:2011-09-24 06:39:24
【问题描述】:
我一直在尝试在 IIS6 上使用 SSL 设置 WCF 传输安全性。
客户端在同一域的不同机器上。
我了解证书、根 CA 等的前提,并且拥有一组用于消息安全的有效证书,并且可以在相同的环境设置中使用这些证书。 (上周我学到的东西不多:)
当我将客户端切换到 SSL 时,我正做着一场噩梦,试图让我的客户端针对 IIS 6 服务进行身份验证。调用时总是收到“不允许匿名身份验证”。
我有 IIS
- 在站点上为 SSL 端口 443 设置的根签名 CA 证书 (如果我浏览 https://svc 页面,我可以看到 IE 挂锁,并且页面显示您需要证书才能进行通信)
在我拥有的安全通信下
- 需要 SSL 通道
- 需要 128 位加密
- 需要客户端证书
- 启用客户端证书映射(设置多对一映射到 IIS 框上的管理员帐户,现在在证书主题 O 字段上匹配)
在网站安全(身份验证和访问控制)下
- 匿名访问 = 开启
- 集成 Windows 身份验证 = 关闭
- 基本身份验证 = 开启
对于客户端 wsHttpBinding,我有一个准备好进行身份验证的证书和一个自定义端点行为来提供此信息,但我认为它还没有走到这一步!
更新的服务器配置
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="CertificateWithTransport">
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WCFServiceCertificate.Service1" behaviorConfiguration="credentialConfig">
<endpoint address="https://svnvmig02/Service1.svc"
binding="wsHttpBinding"
bindingConfiguration="CertificateWithTransport"
contract="WCFServiceCertificate.IService1">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="credentialConfig">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
更新的客户端配置
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://svnvmig02/Service1.svc" binding="wsHttpBinding" behaviorConfiguration="CustomBehavior"
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
name="WSHttpBinding_IService1">
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CustomBehavior">
<clientCredentials>
<clientCertificate findValue="svnvmig02" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My"/>
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
编辑: 可能值得一提的是,我的 VS 项目是 3.5,但 IIS6 运行的是 .net4
通过修改后的配置(感谢 Fabio ;)我现在可以通过 IE 从客户端机器上浏览地址 https://svnvmig01/Service1.svc 并查看生成的 svc 页面,该页面允许我单击也可用的 wsdl URl。
我在网上找到的大多数页面都涉及自托管或 IIS7....我希望 IIS7 支持更好;)
任何帮助将不胜感激:)
【问题讨论】:
-
听起来 IIS 配置正确。请您发布您的服务和客户端配置。
-
嗨法比奥,我想我可能已经退后一步了...IIS配置保持不变,但我已经修改了我得到...。此服务的安全设置需要“匿名”身份验证,但未为托管此服务的 IIS 应用程序启用
-
这篇文章有帮助吗? msdn.microsoft.com/en-us/library/ms731074.aspx。你能把你的配置减少到类似于文章中描述的配置吗?
-
好的 Fabio,我已经更新了配置以反映您发送的链接。我没有提到我在框架 3.5 上,但我从帮助 MSDN 页面的 .net 4 版本中看到,您可以添加 3.5 中不可用的
。可能这是问题,因为我的服务是 3.5,但 IIS6 设置为版本 4? -
您不应该在服务行为中需要
部分,您可以尝试删除它吗?另外,主题名称似乎不匹配?客户端配置有“svnmig02”,服务器配置有“clientCert”。请您详细查看您的证书设置:它们在每台机器上的位置、主题名称、它们是否是自签名的等
标签: wcf security ssl iis-6 transport