【发布时间】:2020-04-28 04:36:17
【问题描述】:
我继承了一项已在 Intranet 上运行了一段时间的服务。安全从来都不是问题,但有人问我是否可以将其暴露在互联网上。
绑定定义
LeanBinding 绑定是继承的,而SecureLeanBinding 是我的猜测。
<bindings>
<customBinding>
<binding name="LeanBinding" closeTimeout="00:10:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
<binaryMessageEncoding compressionFormat="GZip">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binaryMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
<binding name="SecureLeanBinding" closeTimeout="00:10:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
<binaryMessageEncoding compressionFormat="GZip">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binaryMessageEncoding>
<httpsTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"></httpsTransport>
</binding>
</customBinding>
</bindings>
客户端端点
我复制了现有端点,但将地址更改为使用 https,并将绑定配置更改为使用 SucereLeanBinding。
<client>
<endpoint address="http://localhost/APP.Service/" binding="customBinding" bindingConfiguration="LeanBinding" contract="APP.IService" name="customBinding_IService" />
<endpoint address="https://localhost/APP.Service/" binding="customBinding" bindingConfiguration="SecureLeanBinding" contract="APP.IService" name="SecureBinding_IService" />
</client>
服务行为
我将httpsGetEnabled 设置为true
<behaviors>
<endpointBehaviors>
<behavior name="LeanEndPointBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="LeanServiceBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
协议映射
协议映射似乎不会影响服务的行为。但为了完整起见,我将其包括在内。
<protocolMapping>
<add binding="customBinding" bindingConfiguration="SecureLeanBinding" scheme="https"/>
</protocolMapping>
服务定义
我添加了第二个端点和 baseAddress。
<services>
<service name="APP.ServiceName" behaviorConfiguration="LeanServiceBehaviour">
<endpoint address="" binding="customBinding" contract="APP.IService" behaviorConfiguration="LeanEndPointBehaviour" bindingName="LeanBinding" bindingConfiguration="LeanBinding" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="" binding="customBinding" contract="APP.IService" behaviorConfiguration="SecureLeanEndPointBehavior" bindingName="SecureLeanBinding" bindingConfiguration="SecureLeanBinding" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:80/APP.Service/" />
<add baseAddress="https://localhost:443/APP.Service/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
http 绑定有效,但 https 绑定无效。任何帮助将不胜感激。
【问题讨论】:
标签: wcf