Skip to content

[13.1]: Replace RunWithHttpsDevCertificate with WithCertificateKeyPair api #981

Description

@afscrome

Aspire 13.1 is introducing a WithCertificateKeyPair api which can be used to inject the ASP.Net dev cert public/private key into a container. This follows on from the capabilities introduced in 13 to inject certificate trust into containers.

The DevCertHostingExtensions class, and the otel collector using this should be reworked on top of the newer apis.

https://github.com/CommunityToolkit/Aspire/blob/main/src/Shared/DevCertHostingExtensions.cs

if (!settings.ForceNonSecureReceiver && isHttpsEnabled && builder.ExecutionContext.IsRunMode)
{
resourceBuilder.RunWithHttpsDevCertificate();
// Not using `Path.Combine` as we MUST use unix style paths in the container
var certFilePath = $"{DevCertHostingExtensions.DEV_CERT_BIND_MOUNT_DEST_DIR}/{DevCertHostingExtensions.CERT_FILE_NAME}";
var certKeyPath = $"{DevCertHostingExtensions.DEV_CERT_BIND_MOUNT_DEST_DIR}/{DevCertHostingExtensions.CERT_KEY_FILE_NAME}";
if (settings.EnableHttpEndpoint)
{
resourceBuilder.WithArgs(
$@"--config=yaml:receivers::otlp::protocols::http::tls::cert_file: ""{certFilePath}""",
$@"--config=yaml:receivers::otlp::protocols::http::tls::key_file: ""{certKeyPath}""");
}
if (settings.EnableGrpcEndpoint)
{
resourceBuilder.WithArgs(
$@"--config=yaml:receivers::otlp::protocols::grpc::tls::cert_file: ""{certFilePath}""",
$@"--config=yaml:receivers::otlp::protocols::grpc::tls::key_file: ""{certKeyPath}""");
}
}

microsoft/aspire#12506

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions