C# How to change EndpointIdentity in WCF

62 Views Asked by At

Is ServiceHost able to change EndpointIdentity?I wrote below code, but EndpointIdentity' never changed.

var aa = host.AddServiceEndpoint(
                 typeof(IDuplexService),
                 netTcpBinding2,
                 "");

            Uri dnsrelativeAddress = new Uri(host.BaseAddresses[0], "duplex");

The servicehost's Certification'dns name is "sample.com", but I want to change dnsidentity like "identity.com". Because the client's already released and I can't renew dnsidentity easily.

Can I change dnsIdentity Forcibly?

・Certifacate set Code

                var store = new X509Store(StoreName.My, location);
            store.Open(OpenFlags.ReadOnly);
            X509Certificate2 cert = store.Certificates.OfType<X509Certificate2>().FirstOrDefault(
                x => x.Thumbprint == thumbprint
            );
            store.Close();

            host.Credentials.ServiceCertificate.Certificate = cert;
            EndpointAddress epa = new EndpointAddress(dnsrelativeAddress, EndpointIdentity.CreateDnsIdentity("identity.com"));
            aa.Address= epa;
0

There are 0 best solutions below