void SslPopulate() { HttpConfigSslEntry entry = SslFindCurrentEntry(); if (entry != null) { this.sslEdit.Enabled = true; SslPopulateCerts(entry); SslPopulateIPs(); this.sslAddress.Text = entry.EndPoint.Address.ToString(); this.sslAppId.Text = entry.AppId.ToString(); this.sslCertHash.Text = HttpConfigSslEntry.CertHashToString(entry.SslHash); this.sslCertStore.Text = entry.SslCertStoreName; this.sslDownload.Text = entry.DefaultRevocationUrlRetrievalTimeout.Milliseconds.ToString(); this.sslFreshness.Text = entry.DefaultRevocationFreshnessTime.Seconds.ToString(); this.sslPort.Text = entry.EndPoint.Port.ToString(); this.sslNegotiateClientCert.Checked = (entry.DefaultFlags & HTTP_SERVICE_CONFIG_SSL_FLAG.NegotiateClientCert) != 0; this.sslRawFilter.Checked = (entry.DefaultFlags & HTTP_SERVICE_CONFIG_SSL_FLAG.NoRawFilter) != 0; this.sslUseDSMapper.Checked = (entry.DefaultFlags & HTTP_SERVICE_CONFIG_SSL_FLAG.UseDsMapper) != 0; this.sslCheckRevocation.Checked = (entry.DefaultCertCheckMode & HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK.NoCheck) == 0; this.sslCheckOnlyCached.Checked = (entry.DefaultCertCheckMode & HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK.CachedOnly) != 0; this.sslCheckFresh.Checked = (entry.DefaultCertCheckMode & HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK.UseDefaultRevocationFreshnessTime) != 0; this.sslCeckUsage.Checked = (entry.DefaultCertCheckMode & HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK.NoUsage) != 0; } else { this.sslEdit.Enabled = false; SslClear(); } }
void SslPopulateCerts(HttpConfigSslEntry entry) { this.sslCertStore.Items.Clear(); foreach (StoreName store in Enum.GetValues(typeof(StoreName))) { this.sslCertStore.Items.Add(store); } this.sslCertStore.SelectedItem = StoreName.My; }
public HttpConfigSslEntry(IPEndPoint endPoint, string sslHash, Guid appId, string sslCertStoreName, HTTP_SERVICE_CONFIG_SSL_CLIENT_CERT_CHECK defaultCertCheckMode, TimeSpan defaultRevocationFreshnessTime, TimeSpan defaultRevocationUrlRetrievalTimeout, string defaultSslCtlIdentifier, string defaultSslCtlStoreName, HTTP_SERVICE_CONFIG_SSL_FLAG defaultFlags) { this.appId = appId; this.defaultCertCheckMode = defaultCertCheckMode; this.defaultFlags = defaultFlags; this.defaultRevocationFreshnessTime = defaultRevocationFreshnessTime; this.defaultRevocationUrlRetrievalTimeout = defaultRevocationUrlRetrievalTimeout; this.defaultSslCtlIdentifier = defaultSslCtlIdentifier; this.defaultSslCtlStoreName = defaultSslCtlStoreName; this.endPoint = endPoint; this.sslCertStoreName = sslCertStoreName; this.sslHash = HttpConfigSslEntry.CertHashFromString(sslHash); }
HttpConfigSslEntry SslFindCurrentEntry() { if (this.sslTab.SelectedTab == this.sslListTab) { return(this.sslList.SelectedItem as HttpConfigSslEntry); } TreeNode node = this.sslTree.SelectedNode; if (node == null) { return(null); } for (;;) // walk up { HttpConfigSslEntry entry = node.Tag as HttpConfigSslEntry; if (entry != null) { return(entry); } node = node.Parent; if (node == null) { break; } } node = this.sslTree.SelectedNode; for (;;) // walk down { if (node.Nodes.Count != 1) { break; } node = node.FirstNode; HttpConfigSslEntry entry = node.Tag as HttpConfigSslEntry; if (entry != null) { return(entry); } } return(null); }
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(); }
private void sslEdit_Click(object sender, EventArgs e) { sslEditedEntry = SslFindCurrentEntry(); SslSetEditing(true); }
private void sslCancel_Click(object sender, EventArgs e) { sslEditedEntry = null; SslPopulate(); SslSetEditing(false); }
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(); }
public HttpConfigSslEntryInterop(HttpConfigSslEntry entry) : this(entry.EndPoint) { this.entry = entry; }