From 2c0cce61af92c050a6ba1878b39f813a888c52ae Mon Sep 17 00:00:00 2001 From: Tony Fouchard Date: Fri, 15 Dec 2017 11:46:19 +0100 Subject: [PATCH] Manage challenges concurrency --- acme/http.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/acme/http.go b/acme/http.go index fd6018a102..777ad76bfa 100644 --- a/acme/http.go +++ b/acme/http.go @@ -9,12 +9,15 @@ import ( "net/http" "runtime" "strings" + "sync" "time" ) // UserAgent (if non-empty) will be tacked onto the User-Agent string in requests. var UserAgent string +var ConcurrentChallengesNoncesOrderEnsurer sync.Mutex + // HTTPClient is an HTTP client with a reasonable timeout value. var HTTPClient = http.Client{ Transport: &http.Transport{ @@ -104,6 +107,9 @@ func postJSON(j *jws, uri string, reqBody, respBody interface{}) (http.Header, e return nil, errors.New("Failed to marshal network message...") } + ConcurrentChallengesNoncesOrderEnsurer.Lock() + defer ConcurrentChallengesNoncesOrderEnsurer.Unlock() + resp, err := j.post(uri, jsonBytes) if err != nil { return nil, fmt.Errorf("Failed to post JWS message. -> %v", err)