Пример #1
0
        CertRequestContext InitializeRequestContext(RequestNewCertificateOptions options)
        {
            var context = new CertRequestContext();

            try
            {
                context.Registration = RegistrationHelper.LoadFromFile(options.RegisterationFile);
            }catch (Exception ex)
            {
                ConsoleErrorOutput($"Could not load registration file: {ex.Message}");
                goto errorHandling;
            }

            try
            {
                context.Signer = SignerHelper.LoadFromFile(options.SignerFile);
            }
            catch (Exception ex)
            {
                ConsoleErrorOutput($"Could not load signer file: {ex.Message}");
                goto errorHandling;
            }


            try
            {
                var dnsProviderType = AllSupportedDnsProviderTypes[options.DnsProviderName];
                context.DnsProvider = Activator.CreateInstance(dnsProviderType) as IDnsProvider;

                context.DnsProvider.Initialize(options.DnsProviderConfiguration ?? string.Empty);
            }
            catch (Exception ex)
            {
                ConsoleErrorOutput($"Could not initialize dns provider: {ex.Message}");
                goto errorHandling;
            }
            return(context);

errorHandling:
            return(null);
        }