How to configure a secure WCF service behind a firewall?

I have a WCF service, which is located behind the enterprise level firewall, which performs both the host name and port translation, for example:

https://ws.address.com/Service.svchttps://serv.internal.com:44000/Service.svc

The service is protected by SSL-128 and requires a client certificate.

Since the name of the internal server is not accessible from outside the firewall, we had to implement ServiceHostFactory to translate the WSDL and XSD import links generated by WCF:

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 > 0)
                {
                    newBaseAddress.Scheme = baseAddresses[0].Scheme;
                }

                return new Uri[] { newBaseAddress.Uri };
            }
        }
    }

Here's the problem with this: if the service is not hosted on the internal machine using the default SSL port 443, we get an error:

https://ws.address.com/Service.svc '. IIS WAS.

, , 443 44000 44000, . , .

:. , IWsdlExportExtension, WSDL, - svcutil VS2008, .

- ? !

!

+3
5
+1

ip- (- , , ):

https://ws.address.com:44000/Service.svc

, , - WCF https , .

http://msdn.microsoft.com/en-us/library/ms733768.aspx

0

factory. , WSDL. "IWsdlExportExtension", ExportEndpoint, . , .

WSDL... "CreateServiceHost" ! , .

0

. IIS/WAS? , IIS .

IIS

:

cscript //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs 
set W3SVC/1/SecureBindings  "10.(internal addr).1:443:ws.address.com"
"127.0.0.1:443:Internal Host name"

, "routeNpingme" , , https. , ... .

0

, , IIS, serv.internal.com ws.address. .

IIS , URL-. URL- .

, URL...

0

Source: https://habr.com/ru/post/1703076/


All Articles