Fix client example error handling
This commit is contained in:
parent
f785ed12fd
commit
744884127c
|
@ -56,6 +56,7 @@ func init() {
|
||||||
return cert
|
return cert
|
||||||
}
|
}
|
||||||
// Otherwise, generate a certificate
|
// Otherwise, generate a certificate
|
||||||
|
fmt.Println("Generating client certificate for", hostname)
|
||||||
duration := time.Hour
|
duration := time.Hour
|
||||||
cert, err := gmi.NewCertificate(hostname, duration)
|
cert, err := gmi.NewCertificate(hostname, duration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -107,8 +108,10 @@ func sendRequest(req *gmi.Request) error {
|
||||||
case gmi.StatusClassPermanentFailure:
|
case gmi.StatusClassPermanentFailure:
|
||||||
return fmt.Errorf("Permanent failure: %s", resp.Meta)
|
return fmt.Errorf("Permanent failure: %s", resp.Meta)
|
||||||
case gmi.StatusClassCertificateRequired:
|
case gmi.StatusClassCertificateRequired:
|
||||||
fmt.Println("Generating client certificate for", req.Hostname())
|
// Note that this should not happen unless the server responds with
|
||||||
return nil // TODO: Generate and store client certificate
|
// CertificateRequired even after we send a certificate.
|
||||||
|
// CertificateNotAuthorized and CertificateNotValid are handled here.
|
||||||
|
return fmt.Errorf("Certificate required: %s", resp.Meta)
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user