Exemplo n.º 1
0
        public override async Task <AcmeOptions?> Aquire(Target target, IInputService input, RunLevel runLevel)
        {
            var ret = new AcmeOptions();
            Uri?uri = null;

            while (ret.BaseUri == null)
            {
                try
                {
                    var userInput = await input.RequestString("URL of the acme-dns server");

                    uri         = new Uri(userInput);
                    ret.BaseUri = uri.ToString();
                }
                catch { }
            }
            if (uri == null)
            {
                return(null);
            }
            var acmeDnsClient = new AcmeDnsClient(_dnsClient, _proxy, _log, _settings, input, uri);
            var identifiers   = target.Parts.SelectMany(x => x.Identifiers).Distinct();

            foreach (var identifier in identifiers)
            {
                var registrationResult = await acmeDnsClient.EnsureRegistration(identifier.Replace("*.", ""), true);

                if (!registrationResult)
                {
                    return(null);
                }
            }
            return(ret);
        }
Exemplo n.º 2
0
        public override async Task <AcmeOptions> Aquire(Target target, IInputService input, RunLevel runLevel)
        {
            var ret     = new AcmeOptions();
            Uri baseUri = null;

            while (baseUri == null)
            {
                try
                {
                    baseUri = new Uri(await input.RequestString("URL of the acme-dns server"));
                }
                catch { }
            }
            ret.BaseUri = baseUri.ToString();
            var acmeDnsClient = new AcmeDnsClient(_dnsClient, _proxy, _log, _settings, input, ret.BaseUri);
            var identifiers   = target.Parts.SelectMany(x => x.Identifiers).Distinct();

            foreach (var identifier in identifiers)
            {
                if (!await acmeDnsClient.EnsureRegistration(identifier.Replace("*.", ""), true))
                {
                    // Something failed or was aborted
                    return(null);
                }
            }
            return(ret);
        }
Exemplo n.º 3
0
        public override async Task <AcmeOptions?> Default(Target target)
        {
            Uri?baseUri = null;

            try
            {
                var baseUriRaw =
                    _arguments.TryGetRequiredArgument(nameof(AcmeArguments.AcmeDnsServer),
                                                      _arguments.GetArguments <AcmeArguments>().AcmeDnsServer);
                if (!string.IsNullOrEmpty(baseUriRaw))
                {
                    baseUri = new Uri(baseUriRaw);
                }
            }
            catch { }
            if (baseUri == null)
            {
                _log.Error("The value provided for --acmednsserver is not a valid uri");
                return(null);
            }

            var ret = new AcmeOptions
            {
                BaseUri = baseUri.ToString()
            };
            var acmeDnsClient = new AcmeDnsClient(_dnsClient, _proxy, _log, _settings, null, baseUri);
            var identifiers   = target.Parts.SelectMany(x => x.Identifiers).Distinct();
            var valid         = true;

            foreach (var identifier in identifiers)
            {
                if (!await acmeDnsClient.EnsureRegistration(identifier.Replace("*.", ""), false))
                {
                    _log.Warning("No (valid) acme-dns registration could be found for {identifier}.", identifier);
                    valid = false;
                }
            }
            if (!valid)
            {
                _log.Warning($"Creating his renewal might fail because the acme-dns configuration for one or more identifiers looks unhealthy.");
            }
            return(ret);
        }
Exemplo n.º 4
0
        public override async Task <AcmeOptions?> Default(Target target)
        {
            Uri?baseUri = null;

            try
            {
                var baseUriRaw =
                    _arguments.TryGetRequiredArgument(nameof(AcmeArguments.AcmeDnsServer),
                                                      _arguments.GetArguments <AcmeArguments>().AcmeDnsServer);
                if (!string.IsNullOrEmpty(baseUriRaw))
                {
                    baseUri = new Uri(baseUriRaw);
                }
            }
            catch { }
            if (baseUri == null)
            {
                return(null);
            }

            var ret = new AcmeOptions
            {
                BaseUri = baseUri.ToString()
            };
            var acmeDnsClient = new AcmeDnsClient(_dnsClient, _proxy, _log, _settings, null, baseUri);
            var identifiers   = target.Parts.SelectMany(x => x.Identifiers).Distinct();
            var valid         = true;

            foreach (var identifier in identifiers)
            {
                if (!await acmeDnsClient.EnsureRegistration(identifier.Replace("*.", ""), false))
                {
                    valid = false;
                }
            }
            if (!valid)
            {
                _log.Error($"Setting up this certificate is not possible in unattended mode because no (valid) acme-dns registration could be found for one or more of the specified domains.");
                return(null);
            }
            return(ret);
        }
Exemplo n.º 5
0
        public override AcmeOptions Aquire(Target target, IArgumentsService arguments, IInputService input, RunLevel runLevel)
        {
            var ret     = new AcmeOptions();
            Uri baseUri = null;

            while (baseUri == null)
            {
                try
                {
                    baseUri = new Uri(input.RequestString("URL of the acme-dns server"));
                }
                catch { }
            }
            ret.BaseUri = baseUri.ToString();
            var acmeDnsClient = new AcmeDnsClient(_proxy, _log, _settings, input, ret.BaseUri);
            var identifiers   = target.Parts.SelectMany(x => x.Identifiers).Distinct();

            foreach (var identifier in identifiers)
            {
                acmeDnsClient.EnsureRegistration(identifier.Replace("*.", ""));
            }
            return(ret);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Send API call to the acme-dns server
        /// </summary>
        /// <param name="recordName"></param>
        /// <param name="token"></param>
        public override void CreateRecord(string recordName, string token)
        {
            var client = new AcmeDnsClient(_proxy, _log, _settings, _input, _options.BaseUri);

            client.Update(_identifier, token);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Send API call to the acme-dns server
 /// </summary>
 /// <param name="recordName"></param>
 /// <param name="token"></param>
 public override async Task CreateRecord(string recordName, string token)
 {
     var client = new AcmeDnsClient(_dnsClient, _proxy, _log, _settings, _input, new Uri(_options.BaseUri));
     await client.Update(_identifier, token);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Send API call to the acme-dns server
        /// </summary>
        /// <param name="recordName"></param>
        /// <param name="token"></param>
        public override async Task <bool> CreateRecord(DnsValidationRecord record)
        {
            var client = new AcmeDnsClient(_dnsClient, _proxy, _log, _settings, _input, new Uri(_options.BaseUri));

            return(await client.Update(record.Context.Identifier, record.Value));
        }