Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I set up a secure WCF service behind a firewall?
    primarykey
    data
    text
    <p>I have a WCF service that is behind an enterprise-class firewall, which is doing both hostname and port translation, e.g.:</p> <p><a href="https://ws.address.com/Service.svc" rel="nofollow noreferrer">https://ws.address.com/Service.svc</a> --> <a href="https://serv.internal.com:44000/Service.svc" rel="nofollow noreferrer">https://serv.internal.com:44000/Service.svc</a></p> <p>The service is secured with SSL-128 and requires a client certificate.</p> <p>Because the internal server name is not accessible from outside the firewall, we had to implement a ServiceHostFactory to translate the WSDL and XSD import references that WCF generates:</p> <pre><code>public class MyCustomFactory : ServiceHostFactory { protected override ServiceHost CreateServiceHost( Type serviceType, Uri[] baseAddresses) { MyCustomHost customServiceHost = new MyCustomHost(serviceType, baseAddresses); return customServiceHost; } class MyCustomHost : ServiceHost { public MyCustomHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, GetBaseAddresses(serviceType, baseAddresses)) { } protected override void ApplyConfiguration() { base.ApplyConfiguration(); } private static Uri[] GetBaseAddresses( Type serviceType, params Uri[] baseAddresses) { UriBuilder newBaseAddress = new UriBuilder(); newBaseAddress.Path = "/" + serviceType.ToString() + ".svc"; // from config newBaseAddress.Host = MyCustomSettings.ServiceBaseAddress; if (baseAddresses.Length &gt; 0) { newBaseAddress.Scheme = baseAddresses[0].Scheme; } return new Uri[] { newBaseAddress.Uri }; } } } </code></pre> <p>Here's the problem with this: unless the service is hosted on the internal machine on the default SSL port of 443, we get the error:</p> <p><strong><em>No protocol binding matches the given address '<a href="https://ws.address.com/Service.svc" rel="nofollow noreferrer">https://ws.address.com/Service.svc</a>'. Protocol bindings are configured at the Site level in IIS or WAS configuration.</em></strong></p> <p>It appears, from tinkering, that if we change the internal server to host the service on 443, or configure the firewall to forward from 44000 to 44000, everything works. Those aren't options in our production environment, though.</p> <p><strong><em>Edit:</em></strong> Forgot to mention, we tried to use an IWsdlExportExtension to flatten the WSDL, but that caused severe problems with the proxy code generation in svcutil or VS2008, so we scrapped the idea.</p> <p>Does anyone know any way around this? I'm pulling my hair out!</p> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload