From 1b921b158338681df6e08a0346584d20acf8e0d0 Mon Sep 17 00:00:00 2001 From: Daniel Morsing Date: Thu, 10 Jan 2019 14:32:27 +0000 Subject: [PATCH] remove more strict validation Turns out the ACME server can respond with different codes than the ones listed Signed-off-by: Daniel Morsing --- pkg/controller/acmechallenges/sync.go | 8 +------- pkg/controller/acmeorders/sync.go | 21 ++++++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/pkg/controller/acmechallenges/sync.go b/pkg/controller/acmechallenges/sync.go index bec5dc589..bec056b50 100644 --- a/pkg/controller/acmechallenges/sync.go +++ b/pkg/controller/acmechallenges/sync.go @@ -222,13 +222,7 @@ func (c *Controller) syncChallengeStatus(ctx context.Context, cl acmecl.Interfac return err } - switch acmeChallenge.Status { - case acmeapi.StatusPending, acmeapi.StatusValid, acmeapi.StatusInvalid: - // do nothing - default: - // bogus status from acme API that we can't handle. - return fmt.Errorf("acme api returned bogus status for challenge: %v", acmeChallenge.Status) - } + // TODO: should we validate the State returned by the ACME server here? cmState := cmapi.State(acmeChallenge.Status) if cmState == cmapi.Invalid { // be nice to our users and check if there is an error that we diff --git a/pkg/controller/acmeorders/sync.go b/pkg/controller/acmeorders/sync.go index e17f5745f..64dd66c38 100644 --- a/pkg/controller/acmeorders/sync.go +++ b/pkg/controller/acmeorders/sync.go @@ -318,10 +318,7 @@ func (c *Controller) createOrder(ctx context.Context, cl acmecl.Interface, issue return fmt.Errorf("error creating new order: %v", err) } - err = c.setOrderStatus(&o.Status, acmeOrder) - if err != nil { - return err - } + c.setOrderStatus(&o.Status, acmeOrder) chals := make([]cmapi.ChallengeSpec, len(acmeOrder.Authorizations)) // we only set the status.challenges field when we first create the order, @@ -430,7 +427,9 @@ func (c *Controller) syncOrderStatus(ctx context.Context, cl acmecl.Interface, o return err } - return c.setOrderStatus(&o.Status, acmeOrder) + c.setOrderStatus(&o.Status, acmeOrder) + + return nil } func buildChallenge(i int, o *cmapi.Order, chalSpec cmapi.ChallengeSpec) *cmapi.Challenge { @@ -450,14 +449,8 @@ func buildChallenge(i int, o *cmapi.Order, chalSpec cmapi.ChallengeSpec) *cmapi. // setOrderStatus will populate the given OrderStatus struct with the details from // the provided ACME Order. -func (c *Controller) setOrderStatus(o *cmapi.OrderStatus, acmeOrder *acmeapi.Order) error { - switch acmeOrder.Status { - case acmeapi.StatusPending, acmeapi.StatusReady, acmeapi.StatusProcessing, acmeapi.StatusValid, acmeapi.StatusInvalid: - // do nothing - default: - // bogus status from acme API that we can't handle. - return fmt.Errorf("acme api returned bogus status for order: %v", acmeOrder.Status) - } +func (c *Controller) setOrderStatus(o *cmapi.OrderStatus, acmeOrder *acmeapi.Order) { + // TODO: should we validate the State returned by the ACME server here? cmState := cmapi.State(acmeOrder.Status) if cmState == cmapi.Invalid { // be nice to our users and check if there is an error that we @@ -474,8 +467,6 @@ func (c *Controller) setOrderStatus(o *cmapi.OrderStatus, acmeOrder *acmeapi.Ord o.URL = acmeOrder.URL o.FinalizeURL = acmeOrder.FinalizeURL - - return nil } func challengeLabelsForOrder(o *cmapi.Order) map[string]string {