Skip to content

Commit c035c68

Browse files
Improves Http Challenge Server reliability
Enhances Http Challenge Server by improving process startup and error handling. Adds logging for process start failures and timeout issues. Also includes a fix for the executable name on Windows.
1 parent 61947db commit c035c68

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/Certify.Core/Management/CertifyManager/CertifyManager.ManagedCertificates.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ private async Task<bool> StartHttpChallengeServer()
793793

794794
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
795795

796-
var cliPath = System.IO.Path.Combine(AppContext.BaseDirectory, isWindows ? "certify.exe" : "certify");
796+
var cliPath = System.IO.Path.Combine(AppContext.BaseDirectory, isWindows ? "Certify.exe" : "certify");
797797

798798
if (!File.Exists(cliPath) && AppContext.BaseDirectory.IndexOf("service", StringComparison.InvariantCultureIgnoreCase) > -1)
799799
{
@@ -827,10 +827,12 @@ private async Task<bool> StartHttpChallengeServer()
827827
_httpChallengeProcess.Start();
828828
await Task.Delay(1000);
829829
}
830-
catch (Exception)
830+
catch (Exception exp)
831831
{
832832
// failed to start process
833833
_httpChallengeProcess = null;
834+
835+
_serviceLog?.Error($"Http Challenge Server process failed to start {cliPath} {exp}");
834836
return false;
835837
}
836838

@@ -840,7 +842,19 @@ private async Task<bool> StartHttpChallengeServer()
840842
_httpChallengeServerClient.DefaultRequestHeaders.Add("User-Agent", Util.GetUserAgent() + " CertifyManager");
841843
}
842844

843-
return await IsHttpChallengeProcessStarted(true);
845+
var started = await IsHttpChallengeProcessStarted(true);
846+
847+
if (!started)
848+
{
849+
_serviceLog?.Error("Http Challenge Server process failed to start or respond within timeout period.");
850+
851+
return false;
852+
}
853+
else
854+
{
855+
_serviceLog?.Information("Http Challenge Server process started successfully.");
856+
return true;
857+
}
844858
}
845859
else
846860
{

src/Certify.Server/Certify.Server.HubService/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255

256256
app.MapDefaultEndpoints();
257257

258-
app.UseHttpsRedirection();
258+
//app.UseHttpsRedirection();
259259

260260
app.UseResponseCompression();
261261

src/Certify.Shared/Utils/HttpChallengeServer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public bool Start(ServiceConfig serverConfig, string controlKey = null, string c
146146

147147
Log($"Http Challenge Server Started: {uriPrefix}", true);
148148
Log($"Control Key: {_controlKey}: Check Key: {_checkKey}");
149+
Log($"Using API: {_baseUri}");
149150

150151
_ = Task.Run(ServerTask);
151152

0 commit comments

Comments
 (0)