Skip to content

Commit a1c96fc

Browse files
committed
fix ineff assign to err
1 parent 3ea36fd commit a1c96fc

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

command/certificate/create.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,19 @@ func createAction(ctx *cli.Context) error {
327327

328328
if noPass {
329329
_, err = pemutil.Serialize(priv, pemutil.ToFile(keyFile, 0600))
330+
if err != nil {
331+
return errors.WithStack(err)
332+
}
330333
} else {
331334
pass, err := utils.ReadPassword("Please enter the password to encrypt the private key: ")
332335
if err != nil {
333336
return errors.Wrap(err, "error reading password")
334337
}
335338
_, err = pemutil.Serialize(priv, pemutil.WithEncryption(pass),
336339
pemutil.ToFile(keyFile, 0600))
337-
}
338-
if err != nil {
339-
return errors.WithStack(err)
340+
if err != nil {
341+
return errors.WithStack(err)
342+
}
340343
}
341344
return nil
342345
}

command/crypto/keypair.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,19 @@ func createAction(ctx *cli.Context) error {
165165

166166
if noPass {
167167
_, err = pemutil.Serialize(priv, pemutil.ToFile(privFile, 0600))
168+
if err != nil {
169+
return errors.WithStack(err)
170+
}
168171
} else {
169172
pass, err := utils.ReadPassword("Please enter the password to encrypt the private key: ")
170173
if err != nil {
171174
return errors.Wrap(err, "error reading password")
172175
}
173176
_, err = pemutil.Serialize(priv, pemutil.WithEncryption(pass),
174177
pemutil.ToFile(privFile, 0600))
175-
}
176-
if err != nil {
177-
return errors.WithStack(err)
178+
if err != nil {
179+
return errors.WithStack(err)
180+
}
178181
}
179182

180183
return nil

0 commit comments

Comments
 (0)