Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit aeda084

Browse files
author
Christy Henriksson
authored
RevalidateCertificate: DI scopes to fix SQL lifetimes (#651)
1 parent 4c90b75 commit aeda084

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

  • src/Validation.PackageSigning.RevalidateCertificate

src/Validation.PackageSigning.RevalidateCertificate/Job.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,23 @@ public class Job : ValidationJobBase
1919
{
2020
private const string RevalidationConfigurationSectionName = "RevalidateJob";
2121

22-
private ICertificateRevalidator _revalidator;
23-
2422
public override void Init(IServiceContainer serviceContainer, IDictionary<string, string> jobArgsDictionary)
2523
{
2624
base.Init(serviceContainer, jobArgsDictionary);
27-
28-
_revalidator = _serviceProvider.GetRequiredService<ICertificateRevalidator>();
2925
}
3026

3127
public override async Task Run()
3228
{
33-
// Both of these methods only do a chunk of the possible promotion/revalidating work before
34-
// completing. This "Run" method may need to run several times to promote all signatures
35-
// and to revalidate all stale certificates.
36-
await _revalidator.PromoteSignaturesAsync();
37-
await _revalidator.RevalidateStaleCertificatesAsync();
29+
using (var scope = _serviceProvider.CreateScope())
30+
{
31+
var revalidator = scope.ServiceProvider.GetRequiredService<ICertificateRevalidator>();
32+
33+
// Both of these methods only do a chunk of the possible promotion/revalidating work before
34+
// completing. This "Run" method may need to run several times to promote all signatures
35+
// and to revalidate all stale certificates.
36+
await revalidator.PromoteSignaturesAsync();
37+
await revalidator.RevalidateStaleCertificatesAsync();
38+
}
3839
}
3940

4041
protected override void ConfigureJobServices(IServiceCollection services, IConfigurationRoot configurationRoot)

0 commit comments

Comments
 (0)