// Accept informs the server that the client accepts one of its challenges
// previously obtained with c.Authorize.
//
// The server will then perform the validation asynchronously.
Accept informs the server that the client accepts one of its challenges
previously obtained with c.Authorize.

The server will then perform the validation asynchronously.
// Accept informs the server that the client accepts one of its challenges // previously obtained with c . Authorize . // // The server will then perform the validation asynchronously .
func (c *Client) Accept(ctx context.Context, chal *Challenge) (*Challenge, error) {
	auth, err := keyAuth(c.Key.Public(), chal.Token)
	if err != nil {
		return nil, err
	}
	req := struct {
		Resource string `json:"resource"`
		Type     string `json:"type"`
		Auth     string `json:"keyAuthorization"`
	}{
		Resource: "challenge",
		Type:     chal.Type,
		Auth:     auth,
	}
	res, err := c.postJWS(ctx, c.Key, chal.URI, req)
	if err != nil {
		return nil, err
	}
	defer res.Body.Close()
	if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusAccepted {
		return nil, responseError(res)
	}
	var v wireChallenge
	if err := json.NewDecoder(res.Body).Decode(&v); err != nil {
		return nil, fmt.Errorf("acme: invalid response: %v", err)
	}
	return v.challenge(), nil
}
func ( c * Client ) Accept ( ctx context . Context , chal * Challenge ) ( * Challenge , error ) { auth , err := keyAuth ( c . Key . Public ( ) , chal . Token ) if err != nil { return nil , err } req := struct { Resource string `json:"resource"` Type string `json:"type"` Auth string `json:"keyAuthorization"` } { Resource : " " , Type : chal . Type , Auth : auth , } res , err := c . postJWS ( ctx , c . Key , chal . URI , req ) if err != nil { return nil , err } defer res . Body . Close ( ) if res . StatusCode != http . StatusOK && res . StatusCode != http . StatusAccepted { return nil , responseError ( res ) } var v wireChallenge if err := json . NewDecoder ( res . Body ) . Decode ( & v ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } return v . challenge ( ) , nil }
Accept informs the server that the client accepts one of its challenges
previously obtained with c.Authorize.
Accept informs the server that the client accepts one of its challenges previously obtained with c . Authorize .
// Note: the protocol specifies 200 as the expected response code, but // letsencrypt seems to be returning 202.