修复:运行使用客户端证书进行 SSL 身份验证的 IIS 托管 WCF 服务时,将引发 System.NotSupportedException 异常

应用对象
.NET Framework 3.5 Service Pack 1

症状

请考虑以下情形:

  • 创建一个 Windows Communication Foundation (WCF) 服务,该服务托管在 Internet Information Services (IIS) 。
  • 在 WCF 服务中使用 WebScriptEnablingBehavior 类。
  • 将 WCF 服务配置为将客户端证书用于安全套接字层 (SSL) 身份验证。 为此,请将 Web.config 文件中的 ClientCredentialType 属性设置为 Certificate。

在这种情况下,运行 WCF 服务时,将引发 System.NotSupportedException 异常,并收到类似于以下内容的错误消息:

注意

服务“None”的 SSL 设置与 IIS“Ssl, SslNegotiateCert, SslRequireCert, SslMapCert, Ssl128”的 SSL 设置不匹配。

原因

出现此问题的原因是 HttpTransportBindingElement 实例的某些属性未复制到自动生成的 javascript 代理终结点。

解决方法

Microsoft现在提供了受支持的修补程序。 但是,它仅用于更正本文介绍的问题。 仅将其应用于遇到此特定问题的系统。

若要解决此问题,请联系 Microsoft客户支持服务以获取修补程序。 有关Microsoft客户支持服务电话号码的完整列表以及有关支持成本的信息,请访问以下Microsoft网站:

http://support.microsoft.com/contactus/?ws=support注意 在特殊情况下,如果Microsoft 支持部门 Professional 确定特定更新将解决你的问题,则通常由支持呼叫产生的费用可能会被取消。 对于相关特定升级无法解决的其他支持问题和事项,将照常收取支持费用。

先决条件

必须安装 .NET Framework 3.5 Service Pack 1 (SP1) 才能应用此修补程序。

重启要求

安装修补程序后,无需重新启动计算机。

修补程序替代信息

此修补程序不替换任何其他修补程序。
  此修补程序的英文版具有下表中列出的文件属性 (或更高版本的文件属性) 。 这些文件的日期和时间以协调世界时 (UTC) 格式列出。 在查看文件信息时,文件时间将转换为本地时间。 要了解 UTC 与本地时间之间的时差,请使用“控制面板”中“日期和时间”项中的“时区”选项卡。

适用于 Windows Server 2000、Windows Server 2003 和 Windows XP 的基于 x86 的版本

文件名 文件版本 文件大小 日期 时间 平台
System.servicemodel.web.dll 3.5.594.4152 569,344 2009 年 7 月 22 日 01:51 x86

              

适用于 Windows Server 2000、Windows Server 2003 和 Windows XP 的基于 x64 的版本

文件名 文件版本 文件大小 日期 时间 平台
System.servicemodel.web.dll 3.5.594.4152 491,520 2009 年 7 月 22 日 02:13 x64

              

适用于 Windows Server 2000、Windows Server 2003 和 Windows XP 的基于 Itanium 的版本

文件名 文件版本 文件大小 日期 时间 平台
System.servicemodel.web.dll 3.5.594.4152 491,520 2009 年 7 月 22 日 02:26 IA-64

              

状态

Microsoft 已确认在 "适用于" 部分中所列的 Microsoft 产品中存在问题。

解决方法

若要解决此问题,请自承载 WCF 服务,而不是在 IIS 中承载服务。

详细信息

堆栈转储信息

System.ServiceModel.dll!System.ServiceModel.Channels.HttpsChannelListener.ApplyHostedContext(System.ServiceModel.Activation.VirtualPathExtension virtualPathExtension, bool isMetadataListener) + 0x1b7 bytes    

System.ServiceModel.dll!System.ServiceModel.Channels.HttpsTransportBindingElement.BuildChannelListener<System.__Canon>(System.ServiceModel.Channels.BindingContext context) + 0x69 bytes    

  System.ServiceModel.dll!System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener<System.__Canon>() + 0x5f bytes       

System.ServiceModel.dll!System.ServiceModel.Channels.MessageEncodingBindingElement.InternalBuildChannelListener<System.__Canon>(System.ServiceModel.Channels.BindingContext context) + 0x66 bytes    

System.ServiceModel.Web.dll!System.ServiceModel.Channels.WebScriptMetadataMessageEncodingBindingElement.BuildChannelListener<System.__Canon>(System.ServiceModel.Channels.BindingContext context) + 0x4b bytes    

  System.ServiceModel.dll!System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener<System.__Canon>() + 0x5f bytes       

        System.ServiceModel.dll!System.ServiceModel.Channels.Binding.BuildChannelListener<System.__Canon>(System.Uri listenUriBaseAddress, string listenUriRelativeAddress, System.ServiceModel.Description.ListenUriMode listenUriMode, System.ServiceModel.Channels.BindingParameterCollection parameters) + 0xa6 bytes 

        System.ServiceModel.dll!System.ServiceModel.Channels.Binding.BuildChannelListener<System.__Canon>(System.Uri listenUriBaseAddress, System.ServiceModel.Channels.BindingParameterCollection parameters) + 0x7c bytes    

System.ServiceModel.Web.dll!System.ServiceModel.Description.WebScriptEnablingBehavior.AddMetadataEndpoint(System.ServiceModel.Description.ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher, bool debugMode) + 0x698 bytes 

System.ServiceModel.Web.dll!System.ServiceModel.Description.WebScriptEnablingBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher) + 0x60 bytes