(logger *zap.Logger, rw http.ResponseWriter, req *http.Request, valInfo acme.Challenge, distributed bool)
| 263 | } |
| 264 | |
| 265 | func 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 | |
| 294 | const ( |
| 295 | acmeHTTPChallengeBasePath = "/.well-known/acme-challenge" |
no test coverage detected
searching dependent graphs…