Skip to content

Commit

Permalink
Read cert from env var where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
willsawyerrrr committed Oct 10, 2024
1 parent 3b7210d commit 4e4819e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Mortein/Mqtt/Extensions/ServiceCollectionExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ namespace Mortein.Mqtt.Extensions;
public static class ServiceCollectionExtension
{
// TODO: read from somewhere other than the local filesystem.
private static readonly X509Certificate2 certificate = new("/workspaces/api/api.pfx");
private static readonly X509Certificate2 certificate =
Environment.GetEnvironmentVariable("CERTIFICATE") != null ?
new(Environment.GetEnvironmentVariable("CERTIFICATE")!) : // prod
new("/workspaces/api/api.pfx"); // dev

/// <summary>
/// Registers a hosted MQTT client as a service in the <see cref="IServiceCollection" />.
Expand Down

0 comments on commit 4e4819e

Please sign in to comment.