Skip to content

Commit

Permalink
cmd/nebula-cert: fix clobbered error (#1032)
Browse files Browse the repository at this point in the history
* cmd/nebula-cert: fix clobbered error

Signed-off-by: Lars Lehtonen <[email protected]>

* apply suggestions from Nate

This makes it much clearer what is happening in the code

---------

Signed-off-by: Lars Lehtonen <[email protected]>
Co-authored-by: Wade Simmons <[email protected]>
  • Loading branch information
alrs and wadey authored Dec 6, 2023
1 parent 0209402 commit 3a8743d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/nebula-cert/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,22 @@ func ca(args []string, out io.Writer, errOut io.Writer, pr PasswordReader) error
return fmt.Errorf("error while signing: %s", err)
}

var b []byte
if *cf.encryption {
b, err := cert.EncryptAndMarshalSigningPrivateKey(curve, rawPriv, passphrase, kdfParams)
b, err = cert.EncryptAndMarshalSigningPrivateKey(curve, rawPriv, passphrase, kdfParams)
if err != nil {
return fmt.Errorf("error while encrypting out-key: %s", err)
}

err = os.WriteFile(*cf.outKeyPath, b, 0600)
} else {
err = os.WriteFile(*cf.outKeyPath, cert.MarshalSigningPrivateKey(curve, rawPriv), 0600)
b = cert.MarshalSigningPrivateKey(curve, rawPriv)
}

err = os.WriteFile(*cf.outKeyPath, b, 0600)
if err != nil {
return fmt.Errorf("error while writing out-key: %s", err)
}

b, err := nc.MarshalToPEM()
b, err = nc.MarshalToPEM()
if err != nil {
return fmt.Errorf("error while marshalling certificate: %s", err)
}
Expand Down

0 comments on commit 3a8743d

Please sign in to comment.