Пример #1
0
        private void sslDelete_Click(object sender, EventArgs e)
        {
            HttpConfigSslEntry entry = SslFindCurrentEntry();

            if (entry != null)
            {
                DialogResult result = MessageBox.Show("Are you sure you want to delete the following Ssl?\r\n\r\n" + entry.EndPoint, "Confirm Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    try
                    {
                        entry.Delete();
                    }
                    catch (Win32Exception exception)
                    {
                        MessageBox.Show("An error occurred while attempting to delete, the error message was:\r\n\r\n" + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            Reload();
        }
Пример #2
0
        private void sslApply_Click(object sender, EventArgs e)
        {
            bool deleted = false;

            if (sslEditedEntry != null)
            {
                try
                {
                    sslEditedEntry.Delete();
                    deleted = true;
                }
                catch (Win32Exception exception)
                {
                    DialogResult result = MessageBox.Show("An error occurred while attempting to perform the requested change. The error message was:\r\n\r\n" + exception.Message, "Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                    if (result == DialogResult.Abort)
                    {
                        Reload();
                    }
                    if (result != DialogResult.Ignore)
                    {
                        return;
                    }
                }
            }
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(this.sslAddress.Text), int.Parse(this.sslPort.Text));
            Guid       guid     = new Guid();

            try
            {
                guid = new Guid(this.sslAppId.Text);
            }
            catch (FormatException)
            {
            }
            HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK defaultCertCheckMode = 0;

            if (!this.sslCheckRevocation.Checked)
            {
                defaultCertCheckMode |= HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK.NoCheck;
            }
            if (this.sslCheckOnlyCached.Checked)
            {
                defaultCertCheckMode |= HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK.CachedOnly;
            }
            if (this.sslCheckFresh.Checked)
            {
                defaultCertCheckMode |= HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK.UseDefaultRevocationFreshnessTime;
            }
            if (this.sslCeckUsage.Checked)
            {
                defaultCertCheckMode |= HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK.NoUsage;
            }
            HTTP_SERVICE_CONFIG_SSL_FLAG defaultFlags = 0;

            if (this.sslNegotiateClientCert.Checked)
            {
                defaultFlags |= HTTP_SERVICE_CONFIG_SSL_FLAG.NegotiateClientCert;
            }
            if (this.sslRawFilter.Checked)
            {
                defaultFlags |= HTTP_SERVICE_CONFIG_SSL_FLAG.NoRawFilter;
            }
            if (this.sslUseDSMapper.Checked)
            {
                defaultFlags |= HTTP_SERVICE_CONFIG_SSL_FLAG.UseDsMapper;
            }
            double   time;
            TimeSpan sslFreshness = TimeSpan.Zero;

            if (double.TryParse(this.sslFreshness.Text, out time))
            {
                sslFreshness = TimeSpan.FromSeconds(time);
            }
            TimeSpan sslDownload = TimeSpan.Zero;

            if (double.TryParse(this.sslDownload.Text, out time))
            {
                sslDownload = TimeSpan.FromMilliseconds(time);
            }
            HttpConfigSslEntry entry = new HttpConfigSslEntry(endpoint, this.sslCertHash.Text, guid, this.sslCertStore.Text, defaultCertCheckMode, sslFreshness, sslDownload, null, null, defaultFlags);

            try
            {
                entry.Create();
            }
            catch (Win32Exception exception)
            {
                DialogResult result = MessageBox.Show("An error occurred while attempting to perform the requested change. The error message was:\r\n\r\n" + exception.Message, "Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                if (result == DialogResult.Abort)
                {
                    Reload();
                }
                if (result != DialogResult.Ignore)
                {
                    return;
                }
                if (deleted && sslEditedEntry != null)
                {
                    try
                    {
                        sslEditedEntry.Create();
                    }
                    catch (Win32Exception)
                    {
                    }
                }
            }
            sslEditedEntry = null;
            Reload();
        }