WCF SSL证书身份验证无法识别配置设置

时间:2015-11-16 22:44:15

标签: wcf authentication iis ssl

我正在尝试在WCF / .NET 4.0版IIS 7.5中使用SSL证书身份验证,但是,当我启用oneToOneMappings身份验证时,系统无法识别maxReceivedMessageSize,当我注释掉oneToOneMappings身份验证部分时,IIS识别maxReceivedMessageSize变量。

有关如何创建此WCF服务的任何想法都使用我在启用SSL证书身份验证时设置的maxReceivedMessageSize值吗?

服务模式部分:

<system.serviceModel>
    <services>
      <service behaviorConfiguration="AServiceBehavior" name="<IContract>">
        <endpoint address=""  binding="basicHttpBinding" bindingConfiguration="MutualSslBinding" contract="<IContract>"  name="AnEndpoint" />
        <host><baseAddresses><add baseAddress="https://asite.com/service" /></baseAddresses></host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="AServiceBehavior">
          <serviceCredentials>
          </serviceCredentials>
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" />
          <serviceSecurityAudit auditLogLocation="Security" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  <bindings>
      <basicHttpBinding>
        <binding name="MutualSslBinding" axReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                    maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport"> <transport clientCredentialType="Certificate" /></security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true">
    </serviceHostingEnvironment>  
  </system.serviceModel>

证书安全部分:

<system.webServer>
    <security>
      <access sslFlags="Ssl, SslNegotiateCert, SslRequireCert" />
      <authentication>
        <anonymousAuthentication enabled="true" />
        <basicAuthentication enabled="false" />
        <clientCertificateMappingAuthentication enabled="false" />
        <digestAuthentication enabled="false" />
        <windowsAuthentication enabled="false" />
        <iisClientCertificateMappingAuthentication enabled="true" oneToOneCertificateMappingsEnabled="true" manyToOneCertificateMappingsEnabled="true">
          <oneToOneMappings>
                        <clear />
                        <add userName="<LocalUser>" password="<EncryptedPassword>" certificate="<Authentication certificate text>" />
          </oneToOneMappings>
        </iisClientCertificateMappingAuthentication>
      </authentication>
    </security>
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="false" />
  </system.webServer>

1 个答案:

答案 0 :(得分:2)

在这种特定情况下,该问题与WCF配置无关,而与IIS中的uploadReadAheadSize设置无关。

TLS开销

使用SSL证书身份验证时,请求的开销可以在身份验证过程中将大小增加到49Kb以上。

返回错误 413实体太大

使用uploadReadAheadSize控制IIS允许的请求大小。

首先验证IIS请求过滤。

要执行此操作,请打开IIS管理器。选择你的申请。在功能视图中,您将看到“请求过滤”。打开此功能,在右侧面板上,您会看到“编辑功能设置” Maximum Allowed Content Length是一个可选的U-Int属性。它指定请求中内容的最大长度(以字节为单位)。默认值为30000000,大约为28.6MB。 接下来,我们可以在IIS中设置uploadReadAheadSize。

要导航到此设置,请使用以下步骤:

启动&#34; Internet信息服务(IIS)管理器&#34;

  • 展开“服务器”字段
  • 展开网站
  • 选择您的应用所在的网站。
  • 在功能部分,双击&#34;配置编辑器&#34;
  • &#34; Section&#34;选择:system.webServer&gt; serverRuntime

默认设置值为49Kb。

Response provided by Wanjun Dong at MSDN

serverRuntime settings

相关问题