在现有 WCF 服务中为 net.tcp 终结点实现 TLS 时出现问题。套接字连接已中止

Issue when implementing TLS for net.tcp endpoint in existing WCF service. The socket connection was aborted

提问人:Etterz 提问时间:9/8/2023 最后编辑:Etterz 更新时间:9/8/2023 访问量:32

问:

我目前正在为现有的net.tcp端点启用证书身份验证,并收到错误:

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '01:00:00'.

我尝试了多个不同的配置选项,其中一个如下所示。

证书安装在服务器和客户端计算机上,端点存在且端口已打开 - 我只是将证书交换添加到消息中。

希望有人能为我指明正确的方向。

客户:

<system.serviceModel>
    <bindings>
        <netTcpBinding>
            <binding name="NetTcpBinding_ImyService">
                <security mode="Transport">
                    <transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign" />
                </security>
            </binding>
        </netTcpBinding>
    </bindings>
    <client>
        <endpoint address="net.tcp://machine.domain:2790/IPC.myService.svc"
            binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ImyService"
            contract="IPC.ImyService" name="NetTcpBinding_ImyService" behaviorConfiguration="CustomBehavior">
        </endpoint>
    </client>
    <behaviors>
        <endpointBehaviors>
            <behavior name="CustomBehavior">
               <clientCredentials>
                   <clientCertificate findValue="certificateFingerPrint1234abc" x509FindType="FindByThumbprint"
                          storeLocation="LocalMachine" storeName="My" />
                   </clientCredentials>
            </behavior>
        </endpointBehaviors>
    </behaviors>
</system.serviceModel>

服务器:

<system.serviceModel>
  <services>
      <service name="nettcp_IPC.myService" behaviorConfiguration="nettcp_IPC.myServiceBehavior">
          <endpoint 
              address="" 
              binding="netTcpBinding" bindingConfiguration="nettcp_IPC.myServiceBinding"
              contract="IPC.ImyService" />
          <endpoint
              address="mex" 
              binding="mexTcpBinding" 
              contract="IMetadataExchange" />
          <host>
              <baseAddresses>
                  <add baseAddress="net.tcp://machine.domain:2790/IPC.myService.svc"/>
              </baseAddresses>
          </host>
      </service>
  </services>
  <bindings>
      <netTcpBinding>
          <binding name="nettcp_IPC.myServiceBinding"
                   receiveTimeout="00:15:00" 
                   sendTimeout="00:15:00" 
                   maxBufferPoolSize="2147483647" 
                   maxReceivedMessageSize="2147483647">
                  <security mode="Transport">
                      <transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign"/>
                  </security>
          </binding>
    </netTcpBinding>
  </bindings>
  <behaviors>
    <serviceBehaviors>
      <behavior name="nettcp_IPC.myServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>
C# WCF TLS1.2 Net.TCP

评论

0赞 QI You 9/11/2023
我想你可以在这篇文章中得到问题的答案.套接字连接已中止 - CommunicationException

答: 暂无答案