SecurityBindingElement.CreateMutualCertificateDuplexBindingElement in DotNetCore
See original GitHub issueI 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:
- Created 6 years ago
- Comments:15 (6 by maintainers)

Top Related StackOverflow Question
Any updates on this? Are we forever stuck in .Net with no way to move to core/5?
Hi @zhenlan After Almost a year… 😃 Is there any update on this?