Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to show Web Enrollment Endpoint when run from non domain joined machine #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Certify/Lib/HttpUtil.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Net;

namespace Certify.Lib
Expand All @@ -20,12 +20,21 @@ public static bool UrlExists(string url, string authType = "Negotiate")
try
{
using var response = (HttpWebResponse)request.GetResponse();
return response.StatusCode == HttpStatusCode.OK;
return response.StatusCode == HttpStatusCode.OK ||
response.StatusCode == HttpStatusCode.Unauthorized ||
response.StatusCode == HttpStatusCode.Forbidden;
}
catch (WebException)
catch (WebException ex)
{
// Check if the exception is due to Unauthorized (401) or Forbidden (403)
if (ex.Response is HttpWebResponse errorResponse)
{
return errorResponse.StatusCode == HttpStatusCode.Unauthorized ||
errorResponse.StatusCode == HttpStatusCode.Forbidden;
}
}

// If there's an exception or the status code is not one of the expected ones, return false
return false;
}
}
Expand Down