MCPcopy Index your code
hub / github.com/caddyserver/certmagic / answerHTTPValidation

Function answerHTTPValidation

httphandlers.go:265–292  ·  view source on GitHub ↗
(logger *zap.Logger, rw http.ResponseWriter, req *http.Request, valInfo acme.Challenge, distributed bool)

Source from the content-addressed store, hash-verified

263}
264
265func answerHTTPValidation(logger *zap.Logger, rw http.ResponseWriter, req *http.Request, valInfo acme.Challenge, distributed bool) bool {
266 // ensure URL matches
267 validationURL, err := url.Parse(valInfo.URL)
268 if err != nil {
269 logger.Error("got invalid URL from CA",
270 zap.String("file_validation_url", valInfo.URL),
271 zap.Error(err))
272 rw.WriteHeader(http.StatusInternalServerError)
273 return true
274 }
275 if req.URL.Path != validationURL.Path {
276 rw.WriteHeader(http.StatusNotFound)
277 return true
278 }
279
280 rw.Header().Add("Content-Type", "text/plain")
281 req.Close = true
282
283 rw.Write([]byte(valInfo.Token))
284
285 logger.Info("served HTTP validation credential",
286 zap.String("validation_path", valInfo.URL),
287 zap.String("challenge", "http-01"),
288 zap.String("remote", req.RemoteAddr),
289 zap.Bool("distributed", distributed))
290
291 return true
292}
293
294const (
295 acmeHTTPChallengeBasePath = "/.well-known/acme-challenge"

Callers 1

Calls 3

ErrorMethod · 0.80
StringMethod · 0.80
WriteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…