Developer technologies | ASP.NET | ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Dear Experts,
Some service provider gave physical wsdl and certificates, also they provided sample in .net framework 4.7.
In .net framework the below code works
var binding = new BasicHttpsBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
var dns = new DnsEndpointIdentity(ConfigurationManager.AppSettings["DnsEndpointIdentity"]);
var address = new EndpointAddress(new Uri(ConfigurationManager.AppSettings["EndpointAddress"]), dns, new AddressHeader[] { });
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate;
var securityElement = SecurityBindingElement.CreateMutualCertificateBindingElement(MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10, true);
securityElement.IncludeTimestamp = true;
securityElement.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
var customBinding = new CustomBinding(binding);
customBinding.Elements.Insert(0, securityElement);
Client proxy = new Client(customBinding, address);
proxy.ChannelFactory.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;
proxy.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, ConfigurationManager.AppSettings["ClientCertificate"]);
proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
proxy.ClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.LocalMachine, StoreName.Root, X509FindType.FindBySubjectName, ConfigurationManager.AppSettings["ServiceCertificate"]);
proxy.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 3, 0);
return proxy;
Same code not working in .net core 5, please help.
Regards