// SSHCheckHost performs the POST /ssh/check-host request to the CA with the
// given principal.
SSHCheckHost performs the POST /ssh/check-host request to the CA with the
given principal.
// SSHCheckHost performs the POST / ssh / check - host request to the CA with the // given principal .
func (c *Client) SSHCheckHost(principal string, token string) (*api.SSHCheckPrincipalResponse, error) {
	var retried bool
	body, err := json.Marshal(&api.SSHCheckPrincipalRequest{
		Type:      provisioner.SSHHostCert,
		Principal: principal,
		Token:     token,
	})
	if err != nil {
		return nil, errs.Wrap(http.StatusInternalServerError, err, "error marshaling request",
			errs.WithMessage("Failed to marshal the check-host request"))
	}
	u := c.endpoint.ResolveReference(&url.URL{Path: "/ssh/check-host"})
retry:
	resp, err := c.client.Post(u.String(), "application/json", bytes.NewReader(body))
	if err != nil {
		return nil, errs.Wrapf(http.StatusInternalServerError, err, "client POST %s failed",
			[]interface{}{u, errs.WithMessage("Failed to perform POST request to %s", u)}...)
	}
	if resp.StatusCode >= 400 {
		if !retried && c.retryOnError(resp) {
			retried = true
			goto retry
		}
		return nil, errs.StatusCodeError(resp.StatusCode, readError(resp.Body))
	}
	var check api.SSHCheckPrincipalResponse
	if err := readJSON(resp.Body, &check); err != nil {
		return nil, errs.Wrapf(http.StatusInternalServerError, err, "error reading %s response",
			[]interface{}{u, errs.WithMessage("Failed to parse response from /ssh/check-host endpoint")})
	}
	return &check, nil
}
func ( c * Client ) SSHCheckHost ( principal string , token string ) ( * api . SSHCheckPrincipalResponse , error ) { var retried bool body , err := json . Marshal ( & api . SSHCheckPrincipalRequest { Type : provisioner . SSHHostCert , Principal : principal , Token : token , } ) if err != nil { return nil , errs . Wrap ( http . StatusInternalServerError , err , " " , errs . WithMessage ( " " ) ) } u := c . endpoint . ResolveReference ( & url . URL { Path : " " } ) retry : resp , err := c . client . Post ( u . String ( ) , " " , bytes . NewReader ( body ) ) if err != nil { return nil , errs . Wrapf ( http . StatusInternalServerError , err , " " , [ ] interface { } { u , errs . WithMessage ( " " , u ) } ... ) } if resp . StatusCode >= 400 { if ! retried && c . retryOnError ( resp ) { retried = true goto retry } return nil , errs . StatusCodeError ( resp . StatusCode , readError ( resp . Body ) ) } var check api . SSHCheckPrincipalResponse if err := readJSON ( resp . Body , & check ) ; err != nil { return nil , errs . Wrapf ( http . StatusInternalServerError , err , " " , [ ] interface { } { u , errs . WithMessage ( " " ) } ) } return & check , nil }
SSHCheckHost performs the POST /ssh/check-host request to the CA with the
given principal.
SSHCheckHost performs the POST / ssh / check - host request to the CA with the given principal .