Ejemplo n.º 1
0
        private async Task <OrderDetails?> CreateOrder(IEnumerable <Identifier> identifiers, string cacheKey)
        {
            _log.Verbose("Creating order for hosts: {identifiers}", identifiers);
            try
            {
                // TODO: modify AcmeSharp to understand
                // different types of identifier
                var order = await _client.CreateOrder(identifiers);

                if (order.Payload.Error != null)
                {
                    _log.Error("Failed to create order {url}: {detail}", order.OrderUrl, order.Payload.Error.Detail);
                    return(null);
                }
                else
                {
                    _log.Verbose("Order {url} created", order.OrderUrl);
                    SaveOrder(order, cacheKey);
                }
                return(order);
            }
            catch (AcmeProtocolException ex)
            {
                _log.Error($"Failed to create order: {ex.ProblemDetail ?? ex.Message}");
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"Failed to create order");
            }
            return(null);
        }
Ejemplo n.º 2
0
        private async Task <OrderDetails?> CreateOrder(IEnumerable <string> identifiers, string cacheKey)
        {
            _log.Verbose("Creating order for hosts: {identifiers}", identifiers);
            var order = await _client.CreateOrder(identifiers);

            if (order.Payload.Error != null)
            {
                _log.Error("Failed to create order {url}: {detail}", order.OrderUrl, order.Payload.Error.Detail);
                return(null);
            }
            else
            {
                _log.Verbose("Order {url} created", order.OrderUrl);
                SaveOrder(order, cacheKey);
            }
            return(order);
        }
Ejemplo n.º 3
0
        private async Task <OrderDetails?> CreateOrder(IEnumerable <string> identifiers, string cacheKey)
        {
            _log.Verbose("Creating order for hosts: {identifiers}", identifiers);
            var order = await _client.CreateOrder(identifiers);

            // Check if the order is valid
            if ((order.Payload.Status != AcmeClient.OrderReady &&
                 order.Payload.Status != AcmeClient.OrderPending) ||
                order.Payload.Error != null)
            {
                _log.Error("Failed to create order {url}: {detail}", order.OrderUrl, order.Payload.Error.Detail);
                return(null);
            }
            else
            {
                _log.Verbose("Order {url} created", order.OrderUrl);
                SaveOrder(order, cacheKey);
            }
            return(order);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create new order at the server
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <param name="csrPlugin"></param>
        /// <param name="privateKeyFile"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        private async Task <OrderDetails?> CreateOrder(string cacheKey, Target target)
        {
            try
            {
                // Determine final shape of the certificate
                var identifiers = target.GetIdentifiers(false);
                var commonName  = target.CommonName;
                if (!identifiers.Contains(commonName.Unicode(false)))
                {
                    _log.Warning($"Common name {commonName.Value} provided is invalid.");
                    commonName = identifiers.First();
                }

                // Create the order
                _log.Verbose("Creating order for hosts: {identifiers}", identifiers);
                var order = await _client.CreateOrder(identifiers);

                if (order.Payload.Error != null)
                {
                    _log.Error("Failed to create order {url}: {detail}", order.OrderUrl, order.Payload.Error.Detail);
                    return(null);
                }

                _log.Verbose("Order {url} created", order.OrderUrl);
                await SaveOrder(order, cacheKey);

                return(order);
            }
            catch (AcmeProtocolException ex)
            {
                _log.Error($"Failed to create order: {ex.ProblemDetail ?? ex.Message}");
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"Failed to create order");
            }
            return(null);
        }