-
Notifications
You must be signed in to change notification settings - Fork 745
Add Aspire.Hosting.Certbot integration for Certbot container support #13248
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
base: main
Are you sure you want to change the base?
Conversation
…port Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
|
cc @danegsta |
|
@copilot - Lets expose the Certificate and Private Key as propreties on CertbotResource |
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Added |
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13248Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13248" |
1 similar comment
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13248Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13248" |
|
Wonder whether we should make this |
Yeah, it'd be nice to have something that'll work with any ACME compatible certificate source. |
| /// </code> | ||
| /// </example> | ||
| /// </remarks> | ||
| public static IResourceBuilder<T> WithCertbotCertificates<T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're going to have situations where users have multiple certificates (potentially even multiple Certbot certificates) for a resource for different purposes. There might be a server auth (HTTPS) certificate from Let's Encrypt, but also one or more client auth certificates from something like a Vault server on their network.
It's one of the reasons I named the new HTTPS APIs WithServerAuthenticationCertificate to differentiate from future client certificate usage. I think we'll need a similar model for publish time where it's not enough to just have a certificate, we need to consider what it's used for as well.
I'd love to see this integrate with those new APIs so we could do something like:
var certbot = builder.AddCertbot("mydomaincert", "mydomain", "email")
.RunAsDevelopmentCertificate();
builder.AddYarp("gateway")
.WithServerAuthenticationCertificate(certbot);and have everything work at both run and publish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future we'd be able to have builder.AddKeyVaultCertificate("mycert") with the same conventions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does let’s encrypt support issuing more than just server certificates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see we should rename the method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not after February 2026 they don't; but Certbot can be used to retrieve certificates from other providers that support the same protocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a great way to provision client certificates from a Vault server on a private network, for example.
ZeroSSL etc. |
|
Let’s not over engineer the certbot integration. We need concrete implementations to flee out the abstractions. There’s no harm in modeling the concrete container and initially before understanding the abstraction. See also keycloack and oauth |
|
@copilot let’s make this Aspire.Hosting.Certbot |
|
Agree, but I think the right package name is Aspire.Hosting.Certbot because its not actually from LetsEncrypt. But we can make LetsEncrypt the default since that is what everyone normally thinks about. |
…ertbotCertificates to WithServerCertificates Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
|
I don't think we need to solve all the design problems right away, but we will have to effectively have to duplicate publish and run time certificate config until we do. I fully expect we'll end up needing something like: public interface ICertificateResource
{
ReferenceExpression PemFormatCertificate { get; }
ReferenceExpression PemFormatKey { get; }
ReferenceExpression PfxFormatCertificate { get; }
}We'd also need properties to indicate whether a certificate provider can provide the Pfx or Pem format assets (I assume some will only support PFX and others only PEM). But that would be a pattern that we could easily unify with the existing experimental certificate APIs (once we worked out all the other pesky design decisions we'd have to make). |
| /// <strong>Note:</strong> This method may conflict with <c>WithServerAuthenticationCertificateConfiguration</c> | ||
| /// if both are used on the same resource. Only use one certificate configuration method per resource. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WithServerAuthenticationCertificateConfiguration was renamed to WithHttpsCertificateConifguration in main. Also, this comment should reference WithHttpsCertificate and WithHttpsDeveloperCertificate instead of the configuration callback API. Instead of telling users they can't use both APIs, we should instruct them not to use both at runtime; it's totally okay to use certbot and WithHttpsCertificate if certbot is only added when running in publish mode.
We should also add a note that the user needs to configure their application manually when using certbot (ideally with an example of configuring something like yarp via environment variables). The example should probably wrap the certbot config in a publish mode check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot implement this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated documentation in commit e6bba87:
- Changed references from
WithServerAuthenticationCertificateConfigurationtoWithHttpsCertificateandWithHttpsCertificateConfiguration - Clarified that conflicts only occur at runtime, allowing both APIs to coexist when used in different execution modes
- Added comprehensive example showing publish mode usage with
ExecutionContext.IsPublishModecheck - Included manual configuration example using environment variables for YARP
…ion to WithServerHttpsConfiguration in documentation Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
…add publish mode usage example Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
|
Only concern I’ve got is whether we should keep the WithCertificateVolume API too (I’m willing to bet we’d end up removing it in the future). |
|
@copilot lets remove WithCertificateVolume |
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new Aspire.Hosting.Certbot hosting integration that provides support for ACME-based SSL/TLS certificate management via the Certbot container. The integration follows the standard Aspire hosting patterns with resource builders, extension methods, and appropriate test coverage.
Key changes:
- New
CertbotResourceclass representing a Certbot container for certificate provisioning - Extension methods (
AddCertbot,WithHttp01Challenge,WithCertbotCertificate) following Aspire's fluent API patterns - Challenge method configuration through separate extension methods (HTTP-01 initially, with DNS-01 planned for future)
- Comprehensive test coverage including unit tests, manifest validation, and argument null checks
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting.Certbot/Aspire.Hosting.Certbot.csproj | New project file defining the Certbot hosting integration package with appropriate tags and references |
| src/Aspire.Hosting.Certbot/CertbotResource.cs | Core resource class representing a Certbot container with domain/email parameters and certificate path properties |
| src/Aspire.Hosting.Certbot/CertbotBuilderExtensions.cs | Extension methods for adding Certbot resources and configuring challenge methods |
| src/Aspire.Hosting.Certbot/CertbotContainerImageTags.cs | Container image version constants (certbot/certbot:v5.1.0) |
| src/Aspire.Hosting.Certbot/README.md | User-facing documentation for the integration with usage examples and configuration guidance |
| tests/Aspire.Hosting.Certbot.Tests/Aspire.Hosting.Certbot.Tests.csproj | Test project configuration |
| tests/Aspire.Hosting.Certbot.Tests/AddCertbotTests.cs | Comprehensive test suite covering resource creation, annotations, parameters, manifest generation, and edge cases |
| Aspire.slnx | Solution file updated to include the new projects |
…erties section Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
…nimal example per hosting integration guidelines Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Description
Adds
Aspire.Hosting.Certbothosting integration for ACME-based certificate management via Certbot container.New package: Aspire.Hosting.Certbot
CertbotResource- Container resource for SSL/TLS certificate provisioning using ACME protocolAddCertbot()- Extension method to add Certbot with domain/email parameters (challenge methods must be configured separately)WithHttp01Challenge(int? port = 80)- Configures HTTP-01 challenge for domain validation with optional custom portWithCertbotCertificate<T>()- Convenience method that mounts certificates volume and callsWaitForCompletionautomaticallyCertificatePath- Property exposing the path to the SSL/TLS certificate (fullchain.pem)PrivateKeyPath- Property exposing the path to the private key (privkey.pem)/etc/letsencryptfor certificate storageUsage:
API Design:
WithHttp01Challenge(), future:WithDns01Challenge())WithHttp01Challenge()AddCertbotbased on configured challenge method for better compositionAddCertbotcomputes args from that stateWithCertbotCertificateprovides simplified API that automatically handles volume mounting and waiting for completionWithHttpsCertificateandWithHttpsCertificateConfigurationwhen used in different execution modes (e.g., Certbot in publish mode, developer certificates locally)Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplateOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.