Fix for #9950 - HttpsCheck will now retry using the login background image if inital request returns 301/302. Excessvie Headers check will now check the root url instead of the backoffice
This commit is contained in:
committed by
Michael Latouche
parent
3004e00b4f
commit
2b9eaeee8a
@@ -49,7 +49,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
|
|||||||
{
|
{
|
||||||
var message = string.Empty;
|
var message = string.Empty;
|
||||||
var success = false;
|
var success = false;
|
||||||
var url = _runtime.ApplicationUrl;
|
var url = _runtime.ApplicationUrl.GetLeftPart(UriPartial.Authority);
|
||||||
|
|
||||||
// Access the site home page and check for the headers
|
// Access the site home page and check for the headers
|
||||||
var request = WebRequest.Create(url);
|
var request = WebRequest.Create(url);
|
||||||
@@ -69,7 +69,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
message = _textService.Localize("healthcheck/httpsCheckInvalidUrl", new[] { url.ToString(), ex.Message });
|
message = _textService.Localize("healthcheck/healthCheckInvalidUrl", new[] { url.ToString(), ex.Message });
|
||||||
}
|
}
|
||||||
|
|
||||||
var actions = new List<HealthCheckAction>();
|
var actions = new List<HealthCheckAction>();
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Web;
|
|
||||||
using Umbraco.Core;
|
using Umbraco.Core;
|
||||||
using Umbraco.Core.Configuration;
|
using Umbraco.Core.Configuration;
|
||||||
|
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||||
using Umbraco.Core.IO;
|
using Umbraco.Core.IO;
|
||||||
using Umbraco.Core.Services;
|
using Umbraco.Core.Services;
|
||||||
using Umbraco.Web.HealthCheck.Checks.Config;
|
using Umbraco.Web.HealthCheck.Checks.Config;
|
||||||
@@ -21,14 +21,16 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
|
|||||||
private readonly ILocalizedTextService _textService;
|
private readonly ILocalizedTextService _textService;
|
||||||
private readonly IRuntimeState _runtime;
|
private readonly IRuntimeState _runtime;
|
||||||
private readonly IGlobalSettings _globalSettings;
|
private readonly IGlobalSettings _globalSettings;
|
||||||
|
private readonly IContentSection _contentSection;
|
||||||
|
|
||||||
private const string FixHttpsSettingAction = "fixHttpsSetting";
|
private const string FixHttpsSettingAction = "fixHttpsSetting";
|
||||||
|
|
||||||
public HttpsCheck(ILocalizedTextService textService, IRuntimeState runtime, IGlobalSettings globalSettings)
|
public HttpsCheck(ILocalizedTextService textService, IRuntimeState runtime, IGlobalSettings globalSettings, IContentSection contentSection)
|
||||||
{
|
{
|
||||||
_textService = textService;
|
_textService = textService;
|
||||||
_runtime = runtime;
|
_runtime = runtime;
|
||||||
_globalSettings = globalSettings;
|
_globalSettings = globalSettings;
|
||||||
|
_contentSection = contentSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -65,12 +67,25 @@ namespace Umbraco.Web.HealthCheck.Checks.Security
|
|||||||
// Attempt to access the site over HTTPS to see if it HTTPS is supported
|
// Attempt to access the site over HTTPS to see if it HTTPS is supported
|
||||||
// and a valid certificate has been configured
|
// and a valid certificate has been configured
|
||||||
var url = _runtime.ApplicationUrl.ToString().Replace("http:", "https:");
|
var url = _runtime.ApplicationUrl.ToString().Replace("http:", "https:");
|
||||||
|
|
||||||
var request = (HttpWebRequest) WebRequest.Create(url);
|
var request = (HttpWebRequest) WebRequest.Create(url);
|
||||||
request.Method = "HEAD";
|
request.AllowAutoRedirect = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var response = (HttpWebResponse)request.GetResponse();
|
var response = (HttpWebResponse)request.GetResponse();
|
||||||
|
|
||||||
|
// Check for 301/302 as a external login provider such as UmbracoID might be in use
|
||||||
|
if (response.StatusCode == HttpStatusCode.Moved || response.StatusCode == HttpStatusCode.Redirect)
|
||||||
|
{
|
||||||
|
// Reset request to use the static login background image
|
||||||
|
var absoluteLoginBackgroundImage = $"{url}/{_contentSection.LoginBackgroundImage}";
|
||||||
|
|
||||||
|
request = (HttpWebRequest)WebRequest.Create(absoluteLoginBackgroundImage);
|
||||||
|
response = (HttpWebResponse)request.GetResponse();
|
||||||
|
}
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
if (response.StatusCode == HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
// Got a valid response, check now for if certificate expiring within 14 days
|
// Got a valid response, check now for if certificate expiring within 14 days
|
||||||
|
|||||||
Reference in New Issue
Block a user