Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in case of failure use Fatalf #541

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions utils/zts-rolecert/zts-rolecert.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,28 @@ func generateCSR(keySigner *signer, roleDomain, roleName, host, rfc822 string) (
return buf.String(), nil
}

func getRoleCertificate(client *zts.ZTSClient, keySigner *signer, host, rfc822, roleDomain, roleName, roleCertFile string) bool {
func getRoleCertificate(client *zts.ZTSClient, keySigner *signer, host, rfc822, roleDomain, roleName, roleCertFile string) {

var roleRequest = new(zts.RoleCertificateRequest)
csr, err := generateCSR(keySigner, roleDomain, roleName, host, rfc822)
if err != nil {
log.Printf("Unable to generate CSR for %s, err: %v\n", roleName, err)
return false
log.Fatalf("Unable to generate CSR for %s, err: %v\n", roleName, err)
}

roleRequest.Csr = csr
roleToken, err := client.PostRoleCertificateRequest(zts.DomainName(roleDomain), zts.EntityName(roleName), roleRequest)
if err != nil {
log.Printf("PostRoleCertificateRequest failed for %s, err: %v\n", roleName, err)
return false
log.Fatalf("PostRoleCertificateRequest failed for %s, err: %v\n", roleName, err)
}

if roleCertFile != "" {
err = ioutil.WriteFile(roleCertFile, []byte(roleToken.Token), 0444)
if err != nil {
log.Printf("Unable to save role token certificate in %s, err: %v\n", roleCertFile, err)
return false
log.Fatalf("Unable to save role token certificate in %s, err: %v\n", roleCertFile, err)
}
} else {
fmt.Println(roleToken.Token)
}

return true
}

func ztsClient(ztsURL, ztsHostName, keyFile, certFile, caFile string) (*zts.ZTSClient, error) {
Expand Down