sjkp / letsencrypt-azure

The easiest way to use lets encrypt certificates on Azure
110 stars 35 forks source link

Feature Request Install as App Middleware / nuget package #32

Open TehWardy opened 1 year ago

TehWardy commented 1 year ago

I've been trying to get this working with my own CMS. The trouble I've hit is that my CMS handles all paths for a given set of domains. So when I add the extension in to my app my app is handling the URL's that should go to the extension and of course not favorably. If this could be packaged up such that with a bit of config I can serve up auto renewals from my own app code that would be cool.

Is something like this possible?

var domains = new string [] 
{
    "x.com",
    "y.com",
    "z.com"
};

var config = new ConfigurationBuilder()
    .SetBasePath(Directory.GetCurrentDirectory())
    .AddJsonFile("appsettings.json")
    .Build();

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLetsEncrypt(letsEnc=> {
       config.GetSection("LetsEncrypt").Bind(letsEnc);
});

var app = builder.Build();
app.Run();
app.AutoRenewCerts(domains, oneCertPerDomain: true);

This as I see it could be done in a such a way that we don't need external applications or services. It also means that the Lets Encrypt endpoints become part of the app API (solves my problem).

Thoughts?