JRDN
JRDN

Reputation: 11

Perform WCF call in .Net Core with custom binding (authenticationMode="MutualCertificate")

Currently we are facing some issues when calling a WCF service in .net core (2.1).

Because .net core doesn't support the System.Servicemodel binding in the web.config we are trying to create this custom binding programmatically.

(This is well explained in this stackoverflow question: How can I programmatically create this custom binding?)

Our custom binding looks like this:

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

How can we achieve this in code?

In .net framework 4.7.x there was on option to create this binding in this way:

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

But in .net core 2.1 it isn't there. How can we achieve this?

Or how can we do a WCF call in .net core with this custom binding. Kind regards and many thanks for helping us out!

Upvotes: 1

Views: 4451

Answers (1)

Abraham Qian
Abraham Qian

Reputation: 7522

The SOAP message security is not implemented in the WCF client based on DotNet Core. Therefore the AsymmetricSecurityBindingElement could not be created in the Core framework.
https://learn.microsoft.com/en-us/dotnet/api/system.servicemodel.channels.securitybindingelement.createmutualcertificatebindingelement?view=netframework-4.8
https://github.com/dotnet/wcf/issues/2766
Feel free to let me know if there is anything I can help with.

Upvotes: 1

Related Questions