// FetchCert retrieves already issued certificate from the given url, in DER format.
// It retries the request until the certificate is successfully retrieved,
// context is cancelled by the caller or an error response is received.
//
// The returned value will also contain the CA (issuer) certificate if the bundle argument is true.
//
// FetchCert returns an error if the CA's response or chain was unreasonably large.
// Callers are encouraged to parse the returned value to ensure the certificate is valid
// and has expected features.
FetchCert retrieves already issued certificate from the given url, in DER format.
It retries the request until the certificate is successfully retrieved,
context is cancelled by the caller or an error response is received.

The returned value will also contain the CA (issuer) certificate if the bundle argument is true.

FetchCert returns an error if the CA's response or chain was unreasonably large.
Callers are encouraged to parse the returned value to ensure the certificate is valid
and has expected features.
// FetchCert retrieves already issued certificate from the given url in DER format . // It retries the request until the certificate is successfully retrieved // context is cancelled by the caller or an error response is received . // // The returned value will also contain the CA ( issuer ) certificate if the bundle argument is true . // // FetchCert returns an error if the CA ' s response or chain was unreasonably large . // Callers are encouraged to parse the returned value to ensure the certificate is valid // and has expected features .
func (c *Client) FetchCert(ctx context.Context, url string, bundle bool) ([][]byte, error) {
	for {
		res, err := c.get(ctx, url)
		if err != nil {
			return nil, err
		}
		defer res.Body.Close()
		if res.StatusCode == http.StatusOK {
			return c.responseCert(ctx, res, bundle)
		}
		if res.StatusCode > 299 {
			return nil, responseError(res)
		}
		d := retryAfter(res.Header.Get("retry-after"), 3*time.Second)
		select {
		case <-time.After(d):
		case <-ctx.Done():
			return nil, ctx.Err()
		}
	}
}
func ( c * Client ) FetchCert ( ctx context . Context , url string , bundle bool ) ( [ ] [ ] byte , error ) { for { res , err := c . get ( ctx , url ) if err != nil { return nil , err } defer res . Body . Close ( ) if res . StatusCode == http . StatusOK { return c . responseCert ( ctx , res , bundle ) } if res . StatusCode > 299 { return nil , responseError ( res ) } d := retryAfter ( res . Header . Get ( " " ) , 3 * time . Second ) select { case <- time . After ( d ) : case <- ctx . Done ( ) : return nil , ctx . Err ( ) } } }
FetchCert retrieves already issued certificate from the given url, in DER format.
FetchCert retrieves already issued certificate from the given url in DER format .
// retry