【发布时间】:2012-06-06 14:11:15
【问题描述】:
背景:
我在负载均衡器后面的 IIS 7.0 上托管了一项服务,该服务在流量通过它时解密 SSL。
Service所需的安全模式是Mixed-Mode,即TransportWithMessageSecurity
为了使服务能够接受 HTTP 流量,同时允许客户端通过 SSL 与负载均衡器进行通信,我创建了一个用户定义的绑定,它将一个自定义 HttpTransportBindingElement 添加到其通道堆栈中。
自定义的 HttpTransportBindingElement 反过来向框架断言它能够加密和签署消息......因此,当流量通过 HTTP 通过它进入时,框架不会抱怨,因为传输声称它正在签名/加密消息...即使不是。
(对于所有相关人员而言,这已被确定为可接受的安全性,因为消息原本应该通过 SSL 到达负载均衡器...)
问题:
当我们使用 svcutil.exe 生成客户端代理时,生成的自动生成的 app.config 文件包含通过 HTTP 寻址的服务端点。 这应该通过 HTTPS。
此外,
我怀疑这是因为服务器上的框架生成的 WSDL 是使用 HTTP 地址而不是 HTTPS > 而构建的,这是使用自定义 HttpTransportBindingElement(如上所述)的结果。
为客户端自动生成的 app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="myBindingEndpoint">
<!-- WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'http://tempuri.org/': -->
<!-- <wsdl:binding name='myBindingEndpoint'> -->
<!-- <sp:HttpToken xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">..</sp:HttpToken> -->
<security defaultAlgorithmSuite="Default" authenticationMode="CertificateOverTransport"
requireDerivedKeys="true" securityHeaderLayout="Strict" includeTimestamp="true"
keyEntropyMode="CombinedEntropy" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings cacheCookies="true" detectReplays="false"
replayCacheSize="900000" maxClockSkew="00:05:00" maxCookieCachingTime="Infinite"
replayWindow="00:05:00" sessionKeyRenewalInterval="10:00:00"
sessionKeyRolloverInterval="00:05:00" reconnectTransportOnFailure="true"
timestampValidityDuration="00:05:00" cookieRenewalThresholdPercentage="60" />
<localServiceSettings detectReplays="false" issuedCookieLifetime="10:00:00"
maxStatefulNegotiations="128" replayCacheSize="900000" maxClockSkew="00:05:00"
negotiationTimeout="00:01:00" replayWindow="00:05:00" inactivityTimeout="00:02:00"
sessionKeyRenewalInterval="15:00:00" sessionKeyRolloverInterval="00:05:00"
reconnectTransportOnFailure="true" maxPendingSessions="128"
maxCachedCookies="1000" timestampValidityDuration="00:05:00" />
<secureConversationBootstrap />
</security>
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Default" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://myserver/GAEASSLWcfService/ServiceOverSSL.svc"
binding="customBinding" bindingConfiguration="myBindingEndpoint"
contract="IServiceOverSSL" name="myBindingEndpoint" />
</client>
</system.serviceModel>
</configuration>
解决方法:
只需将
但我们宁愿不必指示我们的服务消费者更改他们的 .config 文件...我们的服务的使用应该尽可能的无缝...
问题:
我如何确保客户端代理将使用正确的地址和传输元素自动生成???
参考资料: 对于那些想要了解“负载平衡器/ssl 解密器背后的服务”和自定义 HttpTransportBindingElement 的解决方案的人,请参阅 ZZZ 的这篇文章 XXX 关于构建用户定义的绑定以及 ZZZ 的这篇文章 XXX 关于一些在负载平衡/SSL 加速器后面公开服务的其他问题。
【问题讨论】:
-
您使用哪个 wcf 版本?我相信 .net 4 这个问题是固定的
-
该项目的目标框架是 .Net 4.0 - 所以问题似乎没有解决。
-
您是否曾经设法找到解决 wsdl 问题的方法。我们遇到了同样的问题
标签: wcf ssl load-balancing svcutil.exe