Esempio n. 1
0
        public void ConfigureCertificateStoreProvider()
        {
            ICertificateOptions       options         = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <ICertificateOptions>();
            ICertificateStoreProvider storeProvider   = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <ICertificateStoreProvider>();
            IWebServerVersion         versionProvider = Environment.Host.ApplicationBuilder.ApplicationServices.GetService <IWebServerVersion>();

            const string webHosting = "WebHosting";
            const string my         = "My";

            //
            // My
            if (!storeProvider.Stores.Any(s => s.Name.Equals(my, System.StringComparison.OrdinalIgnoreCase)) && WindowsCertificateStore.Exists(my))
            {
                storeProvider.AddStore(new WindowsCertificateStore(my, new string[] { "read" }));
            }

            if (versionProvider?.Version != null && versionProvider.Version >= new System.Version(8, 0))
            {
                //
                // WebHosting Certificate Store was not introduced until IIS 8.0
                if (!storeProvider.Stores.Any(s => s.Name.Equals(webHosting, System.StringComparison.OrdinalIgnoreCase)) && WindowsCertificateStore.Exists(webHosting))
                {
                    storeProvider.AddStore(new WindowsCertificateStore(webHosting, new string[] { "read" }));
                }
            }
        }
Esempio n. 2
0
        public void ConfigureStoreProvider()
        {
            CertificateStoreProviderAccessor.Services = Environment.Host.ApplicationBuilder.ApplicationServices;
            ICertificateOptions       options       = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <ICertificateOptions>();
            ICertificateStoreProvider storeProvider = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <ICertificateStoreProvider>();


            foreach (var store in options.Stores)
            {
                if (WindowsCertificateStore.Exists(store.Name))
                {
                    storeProvider.AddStore(new WindowsCertificateStore(store.Name, store.Claims));
                }
            }
        }
Esempio n. 3
0
        private void ConfigureStoreProvider()
        {
            ICertificateOptions       options       = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <ICertificateOptions>();
            ICertificateStoreProvider storeProvider = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <ICertificateStoreProvider>();
            IFileProvider             fileProvider  = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <IFileProvider>();

            var ccsOptions = options.Stores.FirstOrDefault(s => s.Name.Equals(STORE_NAME, System.StringComparison.OrdinalIgnoreCase));

            var store = new CentralCertificateStore(STORE_NAME, ccsOptions != null ? ccsOptions.Claims : new string[] { "read" }, fileProvider);

            if (CentralCertHelper.FeatureEnabled && store.Enabled)
            {
                storeProvider.AddStore(store);
            }

            CentralCertificateStore = store;
        }
Esempio n. 4
0
 public CertificatesController(ICertificateOptions options, ICertificateStoreProvider provider)
 {
     _options       = options;
     _storeProvider = provider;
 }