【问题标题】:Perform WCF call in .Net Core with custom binding (authenticationMode="MutualCertificate")使用自定义绑定在 .Net Core 中执行 WCF 调用 (authenticationMode="MutualCertificate")
【发布时间】:2020-07-08 11:54:43
【问题描述】:

目前我们在 .net core (2.1) 中调用 WCF 服务时遇到一些问题。

因为 .net 核心不支持 web.config 中的 System.Servicemodel 绑定,所以我们尝试以编程方式创建此自定义绑定。

(这在这个 stackoverflow 问题中得到了很好的解释:How can I programmatically create this custom binding?

我们的自定义绑定如下所示:

<bindings>
  <customBinding>
    <binding name="customBinding">
      <security enableUnsecuredResponse="true" authenticationMode="MutualCertificate"
        messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" />
      <textMessageEncoding messageVersion="Soap11" />
      <httpsTransport maxReceivedMessageSize="2097152" requireClientCertificate="true" />
    </binding>
  </customBinding>
</bindings>

我们如何在代码中实现这一点?

在 .net 框架 4.7.x 中有一个选项可以以这种方式创建此绑定:

CustomBinding binding = new CustomBinding();
SecurityBindingElement sbe = SecurityBindingElement.CreateMutualCertificateBindingElement();

但在 .net core 2.1 中它不存在。 我们怎样才能做到这一点?

或者我们如何使用这个自定义绑定在 .net 核心中进行 WCF 调用。 亲切的问候,非常感谢您帮助我们!

【问题讨论】:

    标签: asp.net wcf asp.net-core custom-binding


    【解决方案1】:

    基于DotNet Core 的WCF 客户端中没有实现SOAP 消息安全性。因此无法在 Core 框架中创建 AsymmetricSecurityBindingElement
    https://docs.microsoft.com/en-us/dotnet/api/system.servicemodel.channels.securitybindingelement.createmutualcertificatebindingelement?view=netframework-4.8
    https://github.com/dotnet/wcf/issues/2766
    如果有什么我可以帮忙的,请随时告诉我。

    【讨论】:

    • 感谢您的帮助。我们将在 .NET 4.7.2 中创建一个代理来解决这个问题。
    猜你喜欢
    • 2018-08-22
    • 2019-11-21
    • 1970-01-01
    • 2018-06-25
    • 1970-01-01
    • 2013-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多