【问题标题】:WCF SSL certificate authentication not recognizing configuration settingsWCF SSL 证书身份验证无法识别配置设置
【发布时间】:2016-02-18 04:20:32
【问题描述】:

我正在尝试在 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>

【问题讨论】:

    标签: wcf authentication iis ssl


    【解决方案1】:

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

    TLS 开销

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

    返回错误413 Entity Too Large

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

    首先验证 IIS 请求过滤。

    为此,请打开 IIS 管理器。选择您的应用程序。在功能视图中,您将看到“请求过滤”。打开此功能并在右侧面板上找到“编辑功能设置” 最大允许内容长度是一个可选的 U-Int 属性。它指定请求中内容的最大长度,以字节为单位。默认值为 30000000,大约为 28.6MB。 接下来,我们可以在 IIS 中设置 uploadReadAheadSize。

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

    启动“Internet 信息服务 (IIS) 管理器”

    • 扩展服务器字段
    • 扩展网站
    • 选择您的应用程序所在的站点。
    • 在功能部分,双击“配置编辑器”
    • 在“部分”下选择:system.webServer>serverRuntime

    默认设置值为 49Kb。

    Response provided by Wanjun Dong at MSDN

    serverRuntime settings

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-09
      • 2021-12-04
      • 1970-01-01
      • 1970-01-01
      • 2013-08-04
      • 2023-03-14
      • 1970-01-01
      • 2017-04-19
      相关资源
      最近更新 更多