@@ -197,12 +197,6 @@ func (vt *httpValidationTarget) nextIP() error {
197197 return nil
198198}
199199
200- // ip returns the current *net.IP for the validation target. It may return nil
201- // if all possible IPs have been expended by calls to nextIP.
202- func (vt * httpValidationTarget ) ip () net.IP {
203- return vt .cur
204- }
205-
206200// newHTTPValidationTarget creates a httpValidationTarget for the given host,
207201// port, and path. This involves querying DNS for the IP addresses for the host.
208202// An error is returned if there are no usable IP addresses or if the DNS
@@ -369,7 +363,7 @@ func (va *ValidationAuthorityImpl) setupHTTPValidation(
369363 }
370364
371365 // Get the target IP to build a preresolved dialer with
372- targetIP := target .ip ()
366+ targetIP := target .cur
373367 if targetIP == nil {
374368 return nil ,
375369 record ,
@@ -425,20 +419,12 @@ func (va *ValidationAuthorityImpl) processHTTPValidation(
425419 ctx context.Context ,
426420 host string ,
427421 path string ) ([]byte , []core.ValidationRecord , error ) {
428-
429422 // Create a target for the host, port and path with no query parameters
430423 target , err := va .newHTTPValidationTarget (ctx , host , va .httpPort , path , "" )
431424 if err != nil {
432425 return nil , nil , err
433426 }
434427
435- // newIPError implements the error interface. It wraps an error and the IP
436- // of the remote host in an IPError so we can display the IP in the problem
437- // details returned to the client.
438- newIPError := func (target * httpValidationTarget , err error ) error {
439- return ipError {ip : target .cur , err : err }
440- }
441-
442428 // Create an initial GET Request
443429 initialURL := url.URL {
444430 Scheme : "http" ,
@@ -447,7 +433,7 @@ func (va *ValidationAuthorityImpl) processHTTPValidation(
447433 }
448434 initialReq , err := http .NewRequest ("GET" , initialURL .String (), nil )
449435 if err != nil {
450- return nil , nil , newIPError (target , err )
436+ return nil , nil , newIPError (target . cur , err )
451437 }
452438
453439 // Add a context to the request. Shave some time from the
@@ -484,7 +470,7 @@ func (va *ValidationAuthorityImpl) processHTTPValidation(
484470 // Set up the initial validation request and a base validation record
485471 dialer , baseRecord , err := va .setupHTTPValidation (initialReq .URL .String (), target )
486472 if err != nil {
487- return nil , []core.ValidationRecord {}, newIPError (target , err )
473+ return nil , []core.ValidationRecord {}, newIPError (target . cur , err )
488474 }
489475
490476 // Build a transport for this validation that will use the preresolvedDialer's
@@ -606,16 +592,17 @@ func (va *ValidationAuthorityImpl) processHTTPValidation(
606592 // have a fallback address to use and must return the original error.
607593 advanceTargetIPErr := target .nextIP ()
608594 if advanceTargetIPErr != nil {
609- return nil , records , newIPError (target , err )
595+ return nil , records , newIPError (records [ len ( records ) - 1 ]. AddressUsed , err )
610596 }
611597
612598 // setup another validation to retry the target with the new IP and append
613599 // the retry record.
614600 retryDialer , retryRecord , err := va .setupHTTPValidation (initialReq .URL .String (), target )
615- records = append (records , retryRecord )
616601 if err != nil {
617- return nil , records , newIPError (target , err )
602+ return nil , records , newIPError (records [ len ( records ) - 1 ]. AddressUsed , err )
618603 }
604+
605+ records = append (records , retryRecord )
619606 va .metrics .http01Fallbacks .Inc ()
620607 // Replace the transport's dialer with the preresolvedDialer for the retry
621608 // host.
@@ -626,15 +613,15 @@ func (va *ValidationAuthorityImpl) processHTTPValidation(
626613 // If the retry still failed there isn't anything more to do, return the
627614 // error immediately.
628615 if err != nil {
629- return nil , records , newIPError (target , err )
616+ return nil , records , newIPError (retryRecord . AddressUsed , err )
630617 }
631618 } else if err != nil {
632619 // if the error was not a fallbackErr then return immediately.
633- return nil , records , newIPError (target , err )
620+ return nil , records , newIPError (records [ len ( records ) - 1 ]. AddressUsed , err )
634621 }
635622
636623 if httpResponse .StatusCode != 200 {
637- return nil , records , newIPError (target , berrors .UnauthorizedError ("Invalid response from %s: %d" ,
624+ return nil , records , newIPError (records [ len ( records ) - 1 ]. AddressUsed , berrors .UnauthorizedError ("Invalid response from %s: %d" ,
638625 records [len (records )- 1 ].URL , httpResponse .StatusCode ))
639626 }
640627
@@ -646,13 +633,13 @@ func (va *ValidationAuthorityImpl) processHTTPValidation(
646633 err = closeErr
647634 }
648635 if err != nil {
649- return nil , records , newIPError (target , berrors .UnauthorizedError ("Error reading HTTP response body: %v" , err ))
636+ return nil , records , newIPError (records [ len ( records ) - 1 ]. AddressUsed , berrors .UnauthorizedError ("Error reading HTTP response body: %v" , err ))
650637 }
651638
652639 // io.LimitedReader will silently truncate a Reader so if the
653640 // resulting payload is the same size as maxResponseSize fail
654641 if len (body ) >= maxResponseSize {
655- return nil , records , newIPError (target , berrors .UnauthorizedError ("Invalid response from %s: %q" ,
642+ return nil , records , newIPError (records [ len ( records ) - 1 ]. AddressUsed , berrors .UnauthorizedError ("Invalid response from %s: %q" ,
656643 records [len (records )- 1 ].URL , body ))
657644 }
658645
0 commit comments