Skip to content

Commit

Permalink
More wrapped errors - PKI, SSH, Transit (hashicorp#19631)
Browse files Browse the repository at this point in the history
* Add missing wrapped errors in PKI

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add missing wrapped errors in SSH

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add missing wrapped errors in Transit

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

---------

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
  • Loading branch information
cipherboy committed Mar 20, 2023
1 parent 69e2387 commit 89ff5f4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions builtin/logical/pki/crl_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ func writeSpecificRevocationDeltaWALs(sc *storageContext, hyphenSerial string, c
var walInfo deltaWALInfo
walEntry, err := logical.StorageEntryJSON(pathPrefix+hyphenSerial, walInfo)
if err != nil {
return fmt.Errorf("unable to create delta CRL WAL entry")
return fmt.Errorf("unable to create delta CRL WAL entry: %w", err)
}

if err = sc.Storage.Put(sc.Context, walEntry); err != nil {
Expand All @@ -1093,7 +1093,7 @@ func writeSpecificRevocationDeltaWALs(sc *storageContext, hyphenSerial string, c
lastRevSerial := lastWALInfo{Serial: colonSerial}
lastWALEntry, err := logical.StorageEntryJSON(pathPrefix+deltaWALLastRevokedSerialName, lastRevSerial)
if err != nil {
return fmt.Errorf("unable to create last delta CRL WAL entry")
return fmt.Errorf("unable to create last delta CRL WAL entry: %w", err)
}
if err = sc.Storage.Put(sc.Context, lastWALEntry); err != nil {
return fmt.Errorf("error saving last delta CRL WAL entry: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion builtin/logical/pki/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ func (sc *storageContext) fetchRevocationInfo(serial string) (*revocationInfo, e
if revEntry != nil {
err = revEntry.DecodeJSON(&revInfo)
if err != nil {
return nil, fmt.Errorf("error decoding existing revocation info")
return nil, fmt.Errorf("error decoding existing revocation info: %w", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/logical/ssh/path_issue_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (b *creationBundle) sign() (retCert *ssh.Certificate, retErr error) {
// prepare certificate for signing
nonce := make([]byte, 32)
if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
return nil, fmt.Errorf("failed to generate signed SSH key: error generating random nonce")
return nil, fmt.Errorf("failed to generate signed SSH key: error generating random nonce: %w", err)
}
certificate := &ssh.Certificate{
Serial: serialNumber.Uint64(),
Expand Down
2 changes: 1 addition & 1 deletion builtin/logical/transit/path_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func (b *backend) pathPolicyRead(ctx context.Context, req *logical.Request, d *f
}
derived, err := p.GetKey(context, ver, 32)
if err != nil {
return nil, fmt.Errorf("failed to derive key to return public component")
return nil, fmt.Errorf("failed to derive key to return public component: %w", err)
}
pubKey := ed25519.PrivateKey(derived).Public().(ed25519.PublicKey)
key.PublicKey = base64.StdEncoding.EncodeToString(pubKey)
Expand Down

0 comments on commit 89ff5f4

Please sign in to comment.