我试图在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配置无关,而与IIS中的uploadReadAheadSize设置有关。
TLS开销
使用SSL证书身份验证时,请求的开销可能会使身份验证过程中的大小增加到49Kb以上。
返回错误413实体太大
使用uploadReadAheadSize可以控制IIS允许的请求大小。
首先验证IIS请求筛选。
为此,请打开IIS管理器。选择您的应用程序。在“功能”视图中,您将看到“请求过滤”。打开此功能,然后在右侧面板上将找到“编辑功能设置”。“允许的最大内容长度”是一个可选的U-Int属性。它指定请求中内容的最大长度(以字节为单位)。默认值为30000000,大约为28.6MB。接下来,我们可以在IIS中设置uploadReadAheadSize。
要导航到此设置,请使用以下步骤:
启动“ Internet信息服务(IIS)管理器”
默认设置值为49Kb。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句