Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ func (cfg *Config) getACMEChallengeInfo(ctx context.Context, identifier string,
if errors.Is(err, fs.ErrNotExist) {
continue
}
return Challenge{}, false, fmt.Errorf("opening distributed challenge token file %s: %v", tokenKey, err)
return Challenge{}, false, fmt.Errorf("opening distributed challenge token file %s: %w", tokenKey, err)
}
if !challengeFound {
return Challenge{}, false, fmt.Errorf("%w: no information found to solve challenge for identifier: %s", errNoACMEChallengeInfo, identifier)
Expand Down
6 changes: 5 additions & 1 deletion httphandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package certmagic

import (
"context"
"errors"
"fmt"
"net/http"
Expand Down Expand Up @@ -116,7 +117,10 @@ func (am *ACMEIssuer) distributedHTTPChallengeSolver(w http.ResponseWriter, r *h

// couldn't get challenge info even with distributed solver
log := am.Logger.Warn
if errors.Is(err, errNoACMEChallengeInfo) {
switch {
case errors.Is(err, errNoACMEChallengeInfo):
log = am.Logger.Debug
case errors.Is(err, context.Canceled) && errors.Is(r.Context().Err(), context.Canceled):
log = am.Logger.Debug
}
log("looking up info for HTTP challenge",
Expand Down
29 changes: 26 additions & 3 deletions httphandlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ func TestHTTPChallengeHandlerNoOp(t *testing.T) {

func TestHTTPChallengeLookupLogLevel(t *testing.T) {
tests := []struct {
name string
storage Storage
wantLevel zapcore.Level
name string
storage Storage
cancelRequest bool
wantLevel zapcore.Level
}{
{
name: "no active challenge",
Expand All @@ -95,6 +96,23 @@ func TestHTTPChallengeLookupLogLevel(t *testing.T) {
},
wantLevel: zap.WarnLevel,
},
{
name: "request canceled",
storage: loadResultStorage{
Storage: &memoryStorage{},
err: context.Canceled,
},
cancelRequest: true,
wantLevel: zap.DebugLevel,
},
{
name: "storage operation canceled",
storage: loadResultStorage{
Storage: &memoryStorage{},
err: context.Canceled,
},
wantLevel: zap.WarnLevel,
},
{
name: "storage failure",
storage: loadResultStorage{
Expand Down Expand Up @@ -123,6 +141,11 @@ func TestHTTPChallengeLookupLogLevel(t *testing.T) {
"http://example.com/.well-known/acme-challenge/token",
nil,
)
if tt.cancelRequest {
ctx, cancel := context.WithCancel(req.Context())
cancel()
req = req.WithContext(ctx)
}
if am.HandleHTTPChallenge(httptest.NewRecorder(), req) {
t.Fatal("expected challenge request not to be handled")
}
Expand Down
Loading