Пример #1
0
 public AcmeHostedService(ILogger <AcmeHostedService> logger,
                          IServiceProvider services,
                          AcmeOptions options, AcmeState state)
 {
     _logger   = logger;
     _services = services;
     _options  = options;
     _state    = state;
 }
Пример #2
0
 public static IWebHostBuilder AddAcmeServices(this IWebHostBuilder builder, AcmeOptions acmeOptions)
 {
     builder.ConfigureServices(services => {
         services.AddSingleton <AcmeOptions>(acmeOptions);
         services.AddSingleton(AcmeState.Instance);
         services.AddHostedService <AcmeHostedService>();
     });
     builder.UseKestrel((context, options) => options.ConfigureHttpsDefaults(configOpts => {
         configOpts.ServerCertificateSelector = (cc, x) => {
             return(AcmeState.Instance.Certificate);
         };
     }));
     return(builder);
 }
Пример #3
0
        public static IWebHostBuilder AddAcmeServices(this IWebHostBuilder builder,
                                                      IEnumerable <string> dnsNames,
                                                      IEnumerable <string> contactEmails = null,
                                                      bool acceptTos = false,
                                                      string rootDir = null)
        {
            var acmeOptions = new AcmeOptions
            {
                AccountContactEmails = contactEmails,
                AcceptTermsOfService = acceptTos,
                DnsNames             = dnsNames,
            };

            if (rootDir != null)
            {
                acmeOptions.AcmeRootDir = rootDir;
            }
            return(AddAcmeServices(builder, acmeOptions));
        }