Skip to content

Host changes for flex managed certs #10803

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

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private async Task AssignAsync(HostAssignmentContext assignmentContext)
// the host to be specialized
_logger.LogInformation("Applying {environmentCount} app setting(s)", assignmentContext.Environment.Count);
assignmentContext.ApplyAppSettings(_environment, _logger);
assignmentContext.WriteCertificateValidationToken(_logger);
await ApplyContextAsync(assignmentContext);
}
catch (Exception ex)
Expand Down
28 changes: 28 additions & 0 deletions src/WebJobs.Script.WebHost/Models/HostAssignmentContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class HostAssignmentContext
[JsonProperty("TokenServiceApiEndpoint")]
public string TokenServiceApiEndpoint { get; set; }

[JsonProperty("CertificateValidationToken")]
public string CertificateValidationToken { get; set; }

[JsonProperty("CorsSpecializationPayload")]
public CorsSettings CorsSettings { get; set; }

Expand Down Expand Up @@ -165,5 +168,30 @@ public void ApplyAppSettings(IEnvironment environment, ILogger logger)
environment.SetEnvironmentVariable(EnvironmentSettingNames.EasyAuthClientId, EasyAuthSettings.SiteAuthClientId);
}
}

public void WriteCertificateValidationToken(ILogger logger)
{
logger.LogError($"CertificateValidationToken from Antares: CertificateValidationToken");

logger.LogError($"CertificateValidationToken path: {System.IO.Path.GetFullPath(System.IO.Directory.GetCurrentDirectory())}");

if (!string.IsNullOrEmpty(CertificateValidationToken))
{
try
{
if (!System.IO.Directory.Exists("/tmp"))
{
System.IO.Directory.CreateDirectory("/tmp");
}
System.IO.File.WriteAllText("/tmp/domainvalidation", CertificateValidationToken);

logger.LogError($"CertificateValidationToken stored: {CertificateValidationToken.Substring(0, 5)}");
}
catch (Exception ex)
{
logger.LogError($"Failed to write certificate validation token: {ex.Message}");
}
}
}
}
}
Loading