diff --git a/internal/http01fs/http01fs.go b/internal/http01fs/http01fs.go index bfb6268..fb98f7a 100644 --- a/internal/http01fs/http01fs.go +++ b/internal/http01fs/http01fs.go @@ -15,6 +15,7 @@ const ( tmpBase = "acme-tmp" ) +// Provider is the default Challenge Solver Provider var Provider Solver // Solver implements the challenge.Provider interface. @@ -24,14 +25,13 @@ type Solver struct { // Present creates a HTTP-01 Challenge Token func (s *Solver) Present(ctx context.Context, ch acme.Challenge) error { - log.Println("Present HTTP-01 challenge solution for", ch.Identifier.Value) + log.Println("Present HTTP-01 (fs) challenge solution for", ch.Identifier.Value) - myBase := s.Path - if 0 == len(tmpBase) { - myBase = "acme-tmp" + if 0 == len(s.Path) { + s.Path = tmpBase } - challengeBase := filepath.Join(myBase, ch.Identifier.Value, ".well-known/acme-challenge") + challengeBase := filepath.Join(s.Path, ch.Identifier.Value, challengeDir) _ = os.MkdirAll(challengeBase, 0700) tokenPath := filepath.Join(challengeBase, ch.Token) return ioutil.WriteFile(tokenPath, []byte(ch.KeyAuthorization), 0600) @@ -39,15 +39,14 @@ func (s *Solver) Present(ctx context.Context, ch acme.Challenge) error { // CleanUp deletes an HTTP-01 Challenge Token func (s *Solver) CleanUp(ctx context.Context, ch acme.Challenge) error { - log.Println("CleanUp HTTP-01 challenge solution for", ch.Identifier.Value) + log.Println("CleanUp HTTP-01 (fs) challenge solution for", ch.Identifier.Value) - myBase := s.Path - if 0 == len(tmpBase) { - myBase = "acme-tmp" + if 0 == len(s.Path) { + s.Path = tmpBase } // always try to remove, as there's no harm - tokenPath := filepath.Join(myBase, ch.Identifier.Value, challengeDir, ch.Token) + tokenPath := filepath.Join(s.Path, ch.Identifier.Value, challengeDir, ch.Token) _ = os.Remove(tokenPath) return nil