Skip to content
Merged
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
15 changes: 14 additions & 1 deletion src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,20 @@ private static IResourceBuilder<TResource> WithNodeDefaults<TResource>(this IRes
}
else
{
ctx.Arguments.Add("--use-openssl-ca");
if (ctx.EnvironmentVariables.TryGetValue("NODE_OPTIONS", out var existingOptionsObj))
{
ctx.EnvironmentVariables["NODE_OPTIONS"] = existingOptionsObj switch
{
// Attempt to append to existing NODE_OPTIONS if possible, otherwise overwrite
string s when !string.IsNullOrEmpty(s) => $"{s} --use-openssl-ca",
ReferenceExpression re => ReferenceExpression.Create($"{re} --use-openssl-ca"),
_ => "--use-openssl-ca",
};
}
else
{
ctx.EnvironmentVariables["NODE_OPTIONS"] = "--use-openssl-ca";
}
}

return Task.CompletedTask;
Expand Down
5 changes: 4 additions & 1 deletion src/Aspire.Hosting.Yarp/YarpResourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public static IResourceBuilder<YarpResource> AddYarp(
{
ctx.EnvironmentVariables["Kestrel__Certificates__Default__Path"] = ctx.CertificatePath;
ctx.EnvironmentVariables["Kestrel__Certificates__Default__KeyPath"] = ctx.KeyPath;
ctx.EnvironmentVariables["Kestrel__Certificates__Default__Password"] = ctx.Password;
if (ctx.Password is not null)
{
ctx.EnvironmentVariables["Kestrel__Certificates__Default__Password"] = ctx.Password;
}

return Task.CompletedTask;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public sealed class CertificateKeyPairConfigurationCallbackAnnotationContext
/// </code>
/// </example>
/// </remarks>
public required Dictionary<string, object?> EnvironmentVariables { get; init; }
public required Dictionary<string, object> EnvironmentVariables { get; init; }

/// <summary>
/// A value provider that will resolve to a path to the certificate file.
Expand Down
494 changes: 396 additions & 98 deletions src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs

Large diffs are not rendered by default.

787 changes: 184 additions & 603 deletions src/Aspire.Hosting/Dcp/DcpExecutor.cs

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions src/Aspire.Hosting/Dcp/Model/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ internal sealed class ContainerSpec

[JsonPropertyName("createFiles")]
public List<ContainerCreateFileSystem>? CreateFiles { get; set; }

// List of public PEM certificates to be trusted by the container
[JsonPropertyName("pemCertificates")]
public ContainerPemCertificates? PemCertificates { get; set; }
}

internal sealed class BuildContext
Expand Down Expand Up @@ -439,6 +443,25 @@ internal static class ContainerFileSystemEntryType
public const string OpenSSL = "openssl";
}

internal sealed class ContainerPemCertificates
{
// The destination in the container the certificates should be written to
[JsonPropertyName("destination")]
public string? Destination { get; set; }

// The list of PEM encoded certificates to write
[JsonPropertyName("certificates")]
public List<PemCertificate>? Certificates { get; set; }

// Optional list of bundle paths to overwrite in the container with the generated CA bundle
[JsonPropertyName("overwriteBundlePaths")]
public List<string>? OverwriteBundlePaths { get; set; }

// Should resource creation continue if there are errors writing one or more certificates?
[JsonPropertyName("continueOnError")]
public bool ContinueOnError { get; set; }
}

internal sealed record ContainerStatus : V1Status
{
// Container name displayed in Docker
Expand Down
18 changes: 18 additions & 0 deletions src/Aspire.Hosting/Dcp/Model/Executable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ internal sealed class ExecutableSpec
/// </summary>
[JsonPropertyName("ambientEnvironment")]
public AmbientEnvironment? AmbientEnvironment { get; set; }

/// <summary>
/// Public PEM certificates to be configured for the Executable.
/// </summary>
[JsonPropertyName("pemCertificates")]
public ExecutablePemCertificates? PemCertificates { get; set; }
}

internal sealed class AmbientEnvironment
Expand Down Expand Up @@ -101,6 +107,18 @@ internal static class ExecutionType
public const string IDE = "IDE";
}

internal sealed class ExecutablePemCertificates
{
// The list of public PEM encoded certificates for the executable.
[JsonPropertyName("certificates")]
public List<PemCertificate>? Certificates { get; set; }

// Indicates whether to continue starting the Executable if there are issues setting up any certificates for
// the executable.
[JsonPropertyName("continueOnError")]
public bool ContinueOnError { get; set; }
}

internal sealed record ExecutableStatus : V1Status
{
/// <summary>
Expand Down
18 changes: 18 additions & 0 deletions src/Aspire.Hosting/Dcp/Model/PemCertificate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.Json.Serialization;

namespace Aspire.Hosting.Dcp.Model;

// Represents a public PEM encoded certificate
internal sealed class PemCertificate
{
// Thumbprint of the certificate
[JsonPropertyName("thumbprint")]
public string? Thumbprint { get; set; }

// The PEM encoded contents of the public certificate
[JsonPropertyName("contents")]
public string? Contents { get; set; }
}
Loading