From 83886b94e2478b955b7ed7ec81e54613fb011739 Mon Sep 17 00:00:00 2001 From: robvde Date: Wed, 3 Oct 2012 20:52:15 +0400 Subject: [PATCH] Fixed: External IP address bound to SSL binding, now internal dedicated IP SSL Tab only to show website name and domain default choice to include global dns zone during site creation is unchecked When switching SSL enabled site to shared, certificate to be deleted When deleted SSL enabled site, certificate to be deleted Switch IP Mode added to the hosting plan --- WebsitePanel/Database/update_db.sql | 7 +++ .../Packages/Quotas.cs | 1 + .../Code/WebServers/WebServerController.cs | 35 ++++++++++++-- .../WebsitePanel_SharedResources.ascx.resx | 3 ++ .../WebSitesAddSite.ascx.resx | 2 +- .../WebsitePanel/WebSitesAddSite.ascx | 2 +- .../WebsitePanel/WebSitesAddSite.ascx.cs | 2 +- .../WebsitePanel/WebSitesEditSite.ascx.cs | 10 +++- .../WebsitePanel/WebsitesSSL.ascx.cs | 47 ++++++++++++------- 9 files changed, 84 insertions(+), 25 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 1bd00bd6..d72ef1ed 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -473,6 +473,13 @@ INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDe END GO +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Web.AllowIPAddressModeSwitch') +BEGIN + INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (333, 2, 22, N'Web.AllowIPAddressModeSwitch', N'Allow IP Address Mode Switch', 1, 0, NULL) +END +GO + + DELETE FROM [dbo].[PackageQuotas] WHERE [QuotaID] IN (SELECT [QuotaID] FROM [dbo].[Quotas] WHERE [QuotaName] = N'Exchange2007.POP3Enabled') DELETE FROM [dbo].[HostingPlanQuotas] WHERE [QuotaID] IN (SELECT [QuotaID] FROM [dbo].[Quotas] WHERE [QuotaName] = N'Exchange2007.POP3Enabled') diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs index 49d6bc9d..0be7a9d1 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Packages/Quotas.cs @@ -79,6 +79,7 @@ order by rg.groupOrder public const string WEB_CFVIRTUALDIRS = "Web.CFVirtualDirectories"; //ColdFusion Virtual Directories public const string WEB_REMOTEMANAGEMENT = "Web.RemoteManagement"; //IIS 7 Remote Management public const string WEB_SSL = "Web.SSL"; //SSL + public const string WEB_ALLOWIPADDRESSMODESWITCH = "Web.AllowIPAddressModeSwitch"; //SSL public const string FTP_ACCOUNTS = "FTP.Accounts"; // FTP Accounts public const string MAIL_ACCOUNTS = "Mail.Accounts"; // Mail Accounts public const string MAIL_FORWARDINGS = "Mail.Forwardings"; // Mail Forwardings diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/WebServers/WebServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/WebServers/WebServerController.cs index f1fbb0b1..708e00da 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/WebServers/WebServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/WebServers/WebServerController.cs @@ -565,7 +565,15 @@ namespace WebsitePanel.EnterpriseServer // delete web site try { - // remove all web site pointers + //cleanup certificates + //cleanup certificates + List certificates = GetCertificatesForSite(siteItemId); + foreach (SSLCertificate c in certificates) + { + DeleteCertificate(siteItemId, c); + } + + // remove all web site pointers List pointers = GetWebSitePointers(siteItemId); foreach (DomainInfo pointer in pointers) DeleteWebSitePointer(siteItemId, pointer.DomainId, false, true, true); @@ -641,7 +649,6 @@ namespace WebsitePanel.EnterpriseServer DeleteWebSitePointer(siteItemId, pointer.DomainId, true, true, false); // remove web site main pointer - if (domain != null) DeleteWebSitePointer(siteItemId, domain.DomainId, true, true, false); @@ -737,7 +744,13 @@ namespace WebsitePanel.EnterpriseServer if (ZoneInfo == null) throw new Exception("Parent zone not found"); - + //cleanup certificates + List certificates = GetCertificatesForSite(siteItemId); + foreach (SSLCertificate c in certificates) + { + DeleteCertificate(siteItemId, c); + } + // remove all web site pointers List pointers = GetWebSitePointers(siteItemId); foreach (DomainInfo pointer in pointers) @@ -3656,6 +3669,10 @@ Please ensure the space has been allocated {0} IP address as a dedicated one and long ticks = DateTime.UtcNow.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks; ticks /= 10000000; // Convert windows ticks to seconds + //clean up bindings + + + certificate.FriendlyName = String.Format("{0}_{1}", certificate.Hostname, ticks.ToString()); certificate = server.generateCSR(certificate); certificate.id = DataProvider.AddSSLRequest(SecurityContext.User.UserId, item.PackageId, @@ -3692,12 +3709,19 @@ Please ensure the space has been allocated {0} IP address as a dedicated one and WebServer server = GetWebServer(item.ServiceId); TaskManager.WriteParameter("item.ServiceId", item.ServiceId); + IPAddressInfo ip = ServerController.GetIPAddress(item.SiteIPAddressId); + + if (ip != null) + item.SiteIPAddress = !String.IsNullOrEmpty(ip.InternalIP) ? ip.InternalIP : ip.ExternalIP; + certificate = server.installCertificate(certificate, item); if (certificate.SerialNumber == null) { result.AddError("Error_Installing_certificate", null); result.IsSuccess = false; } + + DataProvider.CompleteSSLRequest(SecurityContext.User.UserId, item.PackageId, certificate.id, certificate.Certificate, certificate.DistinguishedName, certificate.SerialNumber, @@ -3735,6 +3759,11 @@ Please ensure the space has been allocated {0} IP address as a dedicated one and WebServer server = GetWebServer(item.ServiceId); TaskManager.WriteParameter("item.ServiceId", item.ServiceId); + // remove all web site pointers + List pointers = GetWebSitePointers(siteItemId); + foreach (DomainInfo pointer in pointers) + DeleteWebSitePointer(siteItemId, pointer.DomainId, true, true, true); + SSLCertificate certificate = server.installPFX(pfx, password, item); if (certificate.SerialNumber == null) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx index 389e3b58..8d392525 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -4855,6 +4855,9 @@ SSL + + Allow IP Address Mode Switch + Exchange Organization diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesAddSite.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesAddSite.ascx.resx index 000c366a..cc91ceb9 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesAddSite.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/WebSitesAddSite.ascx.resx @@ -127,7 +127,7 @@ Cancel - Ignore Zone Template + Include Zone Template ASP.NET Version: diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesAddSite.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesAddSite.ascx index 40235bf6..0e7a59af 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesAddSite.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesAddSite.ascx @@ -23,7 +23,7 @@ + Text="Include Zone Template" Checked="True" /> diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesAddSite.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesAddSite.ascx.cs index 93d85f19..88417d42 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesAddSite.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesAddSite.ascx.cs @@ -107,7 +107,7 @@ namespace WebsitePanel.Portal int packageAddressId = rbDedicatedIP.Checked ? Utils.ParseInt(ddlIpAddresses.SelectedValue, 0) : 0; siteItemId = ES.Services.WebServers.AddWebSite(PanelSecurity.PackageId, txtHostName.Text.ToLower(), domainsSelectDomainControl.DomainId, - packageAddressId, chkIgnoreGlobalDNSRecords.Checked); + packageAddressId, !chkIgnoreGlobalDNSRecords.Checked); if (siteItemId < 0) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs index d9a5f905..d8621dcf 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebSitesEditSite.ascx.cs @@ -197,8 +197,13 @@ namespace WebsitePanel.Portal dedicatedIP.Visible = site.IsDedicatedIP; sharedIP.Visible = !site.IsDedicatedIP; - cmdSwitchToDedicatedIP.Visible = (ddlIpAddresses.Items.Count > 0); - + + PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); + if (Utils.CheckQouta(Quotas.WEB_ALLOWIPADDRESSMODESWITCH, cntx)) + cmdSwitchToDedicatedIP.Visible = (ddlIpAddresses.Items.Count > 0); + else + cmdSwitchToDedicatedIP.Visible = cmdSwitchToSharedIP.Visible = false; + litFrontPageUnavailable.Visible = false; tblSharePoint.Visible = site.SharePointInstalled; @@ -1016,6 +1021,7 @@ namespace WebsitePanel.Portal protected void cmdSwitchToDedicatedIP_Click(object sender, EventArgs e) { + sharedIP.Visible = false; switchToDedicatedIP.Visible = true; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitesSSL.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitesSSL.ascx.cs index a5e71f64..dcd9189b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitesSSL.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/WebsitesSSL.ascx.cs @@ -107,23 +107,11 @@ namespace WebsitePanel.Portal } } - private void BindListOfAvailableSslDomains(ServerBinding[] siteBindings, SSLCertificate[] siteCertificates, string websiteName = "") + private void BindListOfAvailableSslDomains(string websiteName, string domainName) { lstDomains.Items.Clear(); - // - foreach (ServerBinding binding in siteBindings) - { - // - if (binding.IP.ToString().Length > 0 && binding.Host.Length == 0) - { - lstDomains.Items.Add(new ListItem(websiteName, websiteName)); - lstDomains.Items.Add(new ListItem(String.Format("www.{0}", websiteName), String.Format("www.{0}", websiteName))); - } - else - { - lstDomains.Items.Add(new ListItem(binding.Host, binding.Host)); - } - } + lstDomains.Items.Add(new ListItem(websiteName, websiteName)); + lstDomains.Items.Add(new ListItem(domainName, domainName)); } public void BindWebItem(WebVirtualDirectory item) @@ -144,8 +132,20 @@ namespace WebsitePanel.Portal SSLCertificate[] certificates = ES.Services.WebServers.GetCertificatesForSite(item.Id); SSLNotInstalled.Visible = true; + + DomainInfo[] domains = ES.Services.Servers.GetDomains(PanelSecurity.PackageId); + string zoneName = string.Empty; + foreach (DomainInfo d in domains) + { + if (d.WebSiteId == SiteId) + { + zoneName = d.ZoneName; + break; + } + } + // - BindListOfAvailableSslDomains(webSite.Bindings, certificates, webSite.Name); + BindListOfAvailableSslDomains(webSite.Name, zoneName); if (certificates.Length > 0) { @@ -568,7 +568,20 @@ namespace WebsitePanel.Portal SSLNotInstalled.Visible = true; // - BindListOfAvailableSslDomains(item.Bindings, certificates, item.Name); + + DomainInfo[] domains = ES.Services.Servers.GetDomains(PanelSecurity.PackageId); + string zoneName = string.Empty; + foreach (DomainInfo d in domains) + { + if (d.WebSiteId == item.Id) + { + zoneName = d.ZoneName; + break; + } + } + + // + BindListOfAvailableSslDomains(item.Name, zoneName); if (certificates.Length > 0) {