question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SecurityBindingElement.CreateMutualCertificateDuplexBindingElement in DotNetCore

See original GitHub issue

I am trying to use a WSDL service in dot net core that works fine in previous version of dotnet. As I described in https://github.com/dotnet/wcf/issues/2259 and https://github.com/dotnet/wcf/issues/2258 first I tried the ‘Microsoft WCF Web Service Reference Provider’ Extension that result to some errors. then I tried ‘SvcUtil.exe’ and put generated source and config file in a DotNetFramework Console App and was able to successfully connect to the service. but as DotNetCore does not support config file I tried to turn my App.config ‘<system.serviceModel>’ section into code that finally results in this:

        var binding = new CustomBinding()
        {
            Name = "GetCustomsPermitServiceSoapBinding",
        };
        
        var seq = SecurityBindingElement.CreateMutualCertificateDuplexBindingElement(
             MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);

        seq.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic256Sha256Rsa15;
        seq.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
        seq.IncludeTimestamp = true;
        seq.MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
        seq.RequireSignatureConfirmation = false;
        seq.SetKeyDerivation(requireDerivedKeys: false);
        seq.LocalClientSettings.DetectReplays = true;
        seq.LocalServiceSettings.DetectReplays = true;

        binding.Elements.Add(seq);

        binding.Elements.Add(new TextMessageEncodingBindingElement());
        binding.Elements.Add(new HttpTransportBindingElement());

        var endpointAddress = new EndpointAddress(new Uri("http://servicebus.ecogif.ir/IRICA/GetCustomsPermit/4"),
            new DnsEndpointIdentity("servicebus.ecogif.ir"));

        var client = new GetCustomsPermitClient(binding, endpointAddress);
        client.ClientCredentials.ClientCertificate.SetCertificate(storeLocation: StoreLocation.LocalMachine, storeName: StoreName.My, findType: X509FindType.FindBySubjectName,
            findValue: "tamliki.ir");
        client.ClientCredentials.ServiceCertificate.SetDefaultCertificate(storeLocation: StoreLocation.LocalMachine, storeName: StoreName.TrustedPeople, findType: X509FindType.FindBySubjectName,
            findValue: "servicebus.ecogif.ir");

        var pate = client.getCustomsPermitByCustomsPermitNumber("20306133132", "1");`

And It works properly

then I copied this code into a DotNetCore Console App but it seems somethings must be changed as there is no “CreateMutualCertificateDuplexBindingElement” and no “SecurityAlgorithmSuite”

What is the equivalent of this code in DotNetCore?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
dhruvb14commented, Feb 24, 2021

Any updates on this? Are we forever stuck in .Net with no way to move to core/5?

5reactions
inlineHamedcommented, Aug 24, 2018

Hi @zhenlan After Almost a year… 😃 Is there any update on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create SecurityBindingElement in Dot net core 2.1
I am trying to use wcf soap service in dot net core web api project. since dot net core don't support configuration via...
Read more >
How to: Create a SecurityBindingElement for a Specified ...
You can create security binding elements for these authentication modes by using static methods on the SecurityBindingElement class or through ...
Read more >
In this article
Creates an asymmetric security binding element that is configured to require certificate-based client authentication as well as certificate-based server ...
Read more >
SecurityBindingElement.cs source code in C# .NET
Diagnostics; public abstract class SecurityBindingElement ... this method reverses CreateMutualCertificateDuplexBindingElement() logic internal static bool ...
Read more >
C# (CSharp) TransportSecurityBindingElement Examples
C# (CSharp) TransportSecurityBindingElement - 38 examples found. These are the top rated real world C# (CSharp) examples of TransportSecurityBindingElement ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found