Microsoft.Web.Administration.NativeMethods.DeleteSniBinding C# (CSharp) Method

DeleteSniBinding() public static method

public static DeleteSniBinding ( ) : void
return void
        public static void DeleteSniBinding(params Tuple<string, int>[] bindings)
        {
            if (bindings == null || bindings.Length == 0)
                return;

            if (Environment.OSVersion.Version < new Version(6, 2))
            {
                return;
            }

            CallHttpApi(
            delegate
            {
                foreach (var binding in bindings)
                {
                    HTTP_SERVICE_CONFIG_SSL_SNI_SET configSslSet =
                        new HTTP_SERVICE_CONFIG_SSL_SNI_SET();

                    HTTP_SERVICE_CONFIG_SSL_SNI_KEY httpServiceConfigSslKey =
                        new HTTP_SERVICE_CONFIG_SSL_SNI_KEY();
                    httpServiceConfigSslKey.Host = binding.Item1;
                    httpServiceConfigSslKey.IpPort = CreateSockAddrStorageStructure(binding.Item2);
                    configSslSet.KeyDesc = httpServiceConfigSslKey;

                    IntPtr pInputConfigInfo =
                        Marshal.AllocCoTaskMem(
                            Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_SNI_SET)));
                    Marshal.StructureToPtr(configSslSet, pInputConfigInfo, false);

                    try
                    {
                        uint retVal = HttpDeleteServiceConfiguration(IntPtr.Zero,
                                                                        HTTP_SERVICE_CONFIG_ID.HttpServiceConfigSslSniCertInfo,
                                                                        pInputConfigInfo,
                                                                        Marshal.SizeOf(configSslSet),
                                                                        IntPtr.Zero);
                        ThrowWin32ExceptionIfError(retVal);
                    }
                    finally
                    {
                        Marshal.FreeCoTaskMem(pInputConfigInfo);
                    }
                }
            });
        }