Provide access to chosen `X5092Certificate2` in `WithHttpsCertificateConfiguration`
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 201
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
We have some legacy code tat relies on knowing a certificate thumbprint and/or the common name.
In trying to wire this up to `WithHttpsCertificateConfiguration`, I have to make an assumption that the dev cert is used, which may not be true if `WithHttpsCertificate` is used.
```cs
whatever.WithHttpsCertificateConfiguration(ctx =>
{
var devCertService = ctx.ExecutionContext.ServiceProvider.GetRequiredService();
var devCert = devCertService.Certificates.FirstOrDefault()
?? throw new InvalidOperationException("No .Net Developer Certificate found. Ensure you've run 'dotnet dev-certs https --trust'");
ctx.Arguments.Add("-SSLCertificateThumbprint");
ctx.Arguments.Add(devCert.Thumbprint);
return Task.CompletedTask;
});
```
### Describe the solution you'd like
Rather than trying to duplicate Aspire's logic to work out what certificate it thinks I should be using, it would be helpful if the `WithHttpsCertificateConfiguration` callback told me exactly what certificate was chosen.
```cs
whatever.WithHttpsCertificateConfiguration(ctx =>
{
var cert = ctx.Certificate;
ctx.Arguments.Add("-SSLCertificateThumbprint");
ctx.Arguments.Add(cert.Thumbprint);
return Task.CompletedTask;
});
```
### Additional context
cc @danegsta
Contributor guide
Research direction
Start by locating the WithHttpsCertificateConfiguration API and tracing the existing certificate-selection path used by WithHttpsCertificate. Confirm how the selected certificate reaches the callback, then verify that ctx.Certificate exposes that same certificate and that existing HTTPS configuration behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- developer-experience, security
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100