0

我正在将带有 Windows 身份验证的 SSL 安全性添加到以前不安全的 IIS 托管 WCF 服务应用程序中。令我惊讶的是,我发现其中两个服务端点已经在使用 Binding with Transport 和 Windows security。这是令人困惑的,因为使用此服务的客户端应用程序未配置为使用传输安全或 Windows 凭据。这是服务配置:

<binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
    maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    <security mode="Transport">
    <transport clientCredentialType="Windows" />
    </security>
</binding>

...

<service behaviorConfiguration="WebServices.GCServiceBehavior"
    name="WebServices.GCService">
    <endpoint address="" binding="basicHttpBinding" name="GCSecuredEndpoint"
        bindingName="largeBuffer" contract="WebServices.IGCService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>

当我使用 Visual Studio 生成客户端代理和配置时,它会创建以下内容:

<binding name="GCSecuredEndpoint" closeTimeout="00:01:00"
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
    useDefaultWebProxy="true">
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
</binding>

...

<endpoint address="http://devservices.mysite.com/GCService/GCService.svc"
    binding="basicHttpBinding" bindingConfiguration="GCSecuredEndpoint"
    contract="GCSvc.IGCService" name="GCSecuredEndpoint" />

请注意,它是安全模式 =“None”,Transport ClientCredentialType 是 None 而不是 Windows。当我在 GCService 上调用方法时,它会成功。我希望它首先抱怨我试图通过 http 而不是 https 访问,但事实并非如此。接下来,我希望它不会进行身份验证或抱怨客户端端点在身份验证方面与服务不匹配,但事实并非如此。

我在刚刚使用 Transport/Windows 安全设置的同一个应用程序中有另一个服务,只是没有所有缓冲区/读取配额的东西。对于初学者,当我在 VS 中为此服务生成客户端代理/配置时,它会自动使用 https 地址、传输安全性和 Windows 身份验证。如果我手动将其更改为对两者都使用 None ,如上所述,对服务方法之一的调用不会成功,正如预期的那样。为什么上面的 GCService 工作?

4

1 回答 1

0

服务器配置有

bindingName="largeBuffer"

代替

bindingConfiguration="LargeBuffer"

从未使用过 LargeBuffer 绑定配置。

于 2012-08-11T00:41:04.280 回答