Skip to content

Commit

Permalink
add error logging for file not exist vs other errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpmartinez committed Jun 11, 2024
1 parent 442b7bc commit f2ed5f4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions certtools/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ func GetKey(eng *url.URL, file, newkey string) (crypto.PrivateKey, error) {

//verify that it matches what we want, otherwise error
return verifyExistingKey(file, existingKey, newkey)
} else if !os.IsNotExist(err) {
// if the error is anything but "does not exist" we do not know what to do.
return nil, fmt.Errorf("could not read file [%s]: %w", file, err)
}

if newkey == "" {
return nil, fmt.Errorf("no file found at [%s] but a new key spec was not provided", file)
}

//no file exists, but we have a key spec, will generate below
}

if newkey != "" {
Expand Down

0 comments on commit f2ed5f4

Please sign in to comment.