public static CertificateOptions FromConfiguration(IConfiguration configuration)
        {
            var options = new CertificateOptions();

            if (configuration.GetSection("certificates").GetChildren().Count() > 0)
            {
                foreach (var child in configuration.GetSection("certificates:stores").GetChildren())
                {
                    var store = CertificateStoreConfiguration.FromSection(child);
                    if (store != null)
                    {
                        options.AddStore(store);
                    }
                }
            }

            return(options);
        }
Esempio n. 2
0
 public void Use(IServiceCollection services)
 {
     services.AddSingleton <ICertificateOptions>(sp => CertificateOptions.FromConfiguration(sp.GetRequiredService <IConfiguration>()));
     services.AddSingleton <ICertificateStoreProvider>(sp => new CertificateStoreProvider());
 }