Ejemplo n.º 1
0
        private HttpApi.HTTP_SERVICE_CONFIG_SSL_SET ToStruct()
        {
            HttpApi.HTTP_SERVICE_CONFIG_SSL_SET sslStruct = new HttpApi.HTTP_SERVICE_CONFIG_SSL_SET();

            sslStruct.KeyDesc.pIpPort = HttpApi.BuildSockaddr(2, _port, _address);

            if (_hash != null)
            {
                sslStruct.ParamDesc.pSslHash = Marshal.AllocHGlobal(_hash.Length);

                Marshal.Copy(_hash, 0, sslStruct.ParamDesc.pSslHash, _hash.Length);

                sslStruct.ParamDesc.SslHashLength = _hash.Length;
            }

            sslStruct.ParamDesc.AppId                         = _appId;
            sslStruct.ParamDesc.pSslCertStoreName             = _certStoreName;
            sslStruct.ParamDesc.RevocationFreshnessTime       = _revocationFreshnessTime;
            sslStruct.ParamDesc.RevocationUrlRetrievalTimeout = _revocationUrlRetrievalTimeout;
            sslStruct.ParamDesc.pSslCtlIdentifier             = _sslCtlIdentifier;
            sslStruct.ParamDesc.pSslCtlStoreName              = _sslCtlStoreName;
            sslStruct.ParamDesc.Flags                         = _flags;

            sslStruct.ParamDesc.CertCheckMode = _certCheckMode;

            return(sslStruct);
        }
Ejemplo n.º 2
0
        public override void ApplyConfig()
        {
            IntPtr pStruct = IntPtr.Zero;

            HttpApi.HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM setStruct = new HttpApi.HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM();

            try
            {
                setStruct.pAddress = HttpApi.BuildSockaddr(2, 0, _address);

                setStruct.AddrLength = (short)Marshal.SizeOf(typeof(HttpApi.sockaddr));

                pStruct = Marshal.AllocHGlobal(Marshal.SizeOf(setStruct));

                Marshal.StructureToPtr(setStruct, pStruct, false);

                if ((Status == ModifiedStatus.Modified) || (Status == ModifiedStatus.Removed))
                {
                    HttpApi.Error error = HttpApi.HttpDeleteServiceConfiguration(
                        IntPtr.Zero,
                        HttpApi.HTTP_SERVICE_CONFIG_ID.HttpServiceConfigIPListenList,
                        pStruct,
                        Marshal.SizeOf(setStruct),
                        IntPtr.Zero);

                    if (error != HttpApi.Error.NO_ERROR)
                    {
                        throw new HttpApiException(error, "HttpDeleteServiceConfiguration (IPLISTEN) failed.  Error = " + error);
                    }
                }

                if ((Status == ModifiedStatus.Modified) || (Status == ModifiedStatus.Added))
                {
                    HttpApi.Error error = HttpApi.HttpSetServiceConfiguration(
                        IntPtr.Zero,
                        HttpApi.HTTP_SERVICE_CONFIG_ID.HttpServiceConfigIPListenList,
                        pStruct,
                        Marshal.SizeOf(setStruct),
                        IntPtr.Zero);

                    if (error != HttpApi.Error.NO_ERROR)
                    {
                        throw new HttpApiException(error, "HttpSetServiceConfiguration (IPLISTEN) failed.  Error = " + error);
                    }
                }
            }
            finally
            {
                if (setStruct.pAddress != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(setStruct.pAddress);
                }

                if (pStruct != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(pStruct);
                }
            }
        }