Skip to content

Commit d5eff9f

Browse files
chore(core): Log kas URI on key index requests (#2710)
### Proposed Changes * This is helpful for figuring out if the index is misconfigured ### Checklist - [ ] I have added or updated unit tests - [ ] I have added or updated integration tests (if appropriate) - [ ] I have added or updated documentation ### Testing Instructions
1 parent 00354b3 commit d5eff9f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

service/kas/key_indexer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func convertAlgToEnum(alg string) (policy.Algorithm, error) {
8181
}
8282
}
8383

84+
func (p *KeyIndexer) String() string {
85+
return fmt.Sprintf("PlatformKeyIndexer[%s]", p.kasURI)
86+
}
87+
8488
func (p *KeyIndexer) FindKeyByAlgorithm(ctx context.Context, algorithm string, includeLegacy bool) (trust.KeyDetails, error) {
8589
alg, err := convertAlgToEnum(algorithm)
8690
if err != nil {

service/trust/delegating_key_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (d *DelegatingKeyService) Name() string {
9090
func (d *DelegatingKeyService) Decrypt(ctx context.Context, keyID KeyIdentifier, ciphertext []byte, ephemeralPublicKey []byte) (ProtectedKey, error) {
9191
keyDetails, err := d.index.FindKeyByID(ctx, keyID)
9292
if err != nil {
93-
return nil, fmt.Errorf("unable to find key by ID '%s': %w", keyID, err)
93+
return nil, fmt.Errorf("unable to find key by ID '%s' within index %s: %w", keyID, d.index, err)
9494
}
9595

9696
manager, err := d.getKeyManager(keyDetails.System())
@@ -104,7 +104,7 @@ func (d *DelegatingKeyService) Decrypt(ctx context.Context, keyID KeyIdentifier,
104104
func (d *DelegatingKeyService) DeriveKey(ctx context.Context, keyID KeyIdentifier, ephemeralPublicKeyBytes []byte, curve elliptic.Curve) (ProtectedKey, error) {
105105
keyDetails, err := d.index.FindKeyByID(ctx, keyID)
106106
if err != nil {
107-
return nil, fmt.Errorf("unable to find key by ID '%s': %w", keyID, err)
107+
return nil, fmt.Errorf("unable to find key by ID '%s' in index %s: %w", keyID, d.index, err)
108108
}
109109

110110
manager, err := d.getKeyManager(keyDetails.System())

0 commit comments

Comments
 (0)