diff options
| author | adnano <[email protected]> | 2020-09-28 14:26:09 -0400 |
|---|---|---|
| committer | adnano <[email protected]> | 2020-09-28 14:26:09 -0400 |
| commit | 744884127cd019454174cc768a98bc0e7cd8f5a3 (patch) | |
| tree | b013a3e2c3ff25e43e2a32d8e80de5b2a6fe380f /examples/client | |
| parent | examples/client: Disable echo for sensitive input (diff) | |
| download | go-gemini-744884127cd019454174cc768a98bc0e7cd8f5a3.tar.xz go-gemini-744884127cd019454174cc768a98bc0e7cd8f5a3.zip | |
Fix client example error handling
Diffstat (limited to 'examples/client')
| -rw-r--r-- | examples/client/client.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/client/client.go b/examples/client/client.go index 5582597..be7fe23 100644 --- a/examples/client/client.go +++ b/examples/client/client.go @@ -56,6 +56,7 @@ func init() { return cert } // Otherwise, generate a certificate + fmt.Println("Generating client certificate for", hostname) duration := time.Hour cert, err := gmi.NewCertificate(hostname, duration) if err != nil { @@ -107,8 +108,10 @@ func sendRequest(req *gmi.Request) error { case gmi.StatusClassPermanentFailure: return fmt.Errorf("Permanent failure: %s", resp.Meta) case gmi.StatusClassCertificateRequired: - fmt.Println("Generating client certificate for", req.Hostname()) - return nil // TODO: Generate and store client certificate + // Note that this should not happen unless the server responds with + // CertificateRequired even after we send a certificate. + // CertificateNotAuthorized and CertificateNotValid are handled here. + return fmt.Errorf("Certificate required: %s", resp.Meta) } panic("unreachable") } |