Unofficial implementation of the German rules for validating a Digital Green Certificate
$ dotnet add package DgcReader.RuleValidators.GermanyImplementation of IRulesValidator for validating Digital Green Certificates using rules provided by the German backend.
This is an unofficial porting of the covpass-sdk included in the Digitaler-Impfnachweis / covpass-android repository.
In addition to German rules, it supports validation for several other European Union countries. You can get a list of supported countries by calling the GetSupportedCountries method.
In order to use the validator, you can register it as a service or you can instantiate it directly, depending on how your application is designed:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddDgcReader()
.AddGermanTrustListProvider()
.AddGermanRulesValidator(o =>
{
// Optionally, configure the validator with custom options
o.RefreshInterval = TimeSpan.FromSeconds(5);
o.MinRefreshInterval = TimeSpan.Zero;
...
});
}
...
// You can use the constructor
var rulesValidator = new DgcItalianRulesValidator(httpClient);
...
// Or you can use the DgcItalianRulesValidator.Create facory method
// This will help you to unwrap the IOptions interface when you specify
// custom options for the provider:
var rulesValidator = DgcGermanRulesValidator.Create(httpClient,
new DgcGermanRulesValidatorOptions {
RefreshInterval = TimeSpan.FromHours(24),
MinRefreshInterval = TimeSpan.FromHours(1),
});
// Then you should pass it as a parameter to the DgcReaderService constructor:
var dgcReader = DgcReaderService.Create(
trustListProvider,
null,
rulesValidator // <-- The rules validator service
);
RefreshInterval is expired, subsequent validation requests won't try to download the updated rules for 5 minutes before making a new attempt.
Default value is 5 minutes.MaxFileAge value.Directory.GetCurrentDirectory()If the application needs to update the rules at a specific time (i.e. by a scheduled task, or when a user press a "Refresh" button), you can simply call the RefreshRulesList function of the validator.
This will casue the immediate refresh of the rules from the remote server, regardless of the options specified.
This library is not an official implementation, therefore its use may be subject to restrictions by some countries regulations.
The author assumes no responsibility for any unauthorized use of the library and no warranties about the correctness of the implementation, as better stated in the License.
Copyright © 2021 Davide Trevisan
Licensed under the Apache License, Version 2.0