@@ -105,7 +105,7 @@ func kmsSignerFromClient(ctx context.Context, client KMSClient, keyName string,
105105 return nil , fmt .Errorf ("gcp kms client is required" )
106106 }
107107
108- o := Options {Timeout : 10 * time .Second , MaxRetries : 3 }
108+ o := Options {Timeout : 1 * time .Second , MaxRetries : 3 }
109109 if opts != nil {
110110 if opts .Timeout > 0 {
111111 o .Timeout = opts .Timeout
@@ -181,6 +181,9 @@ func (s *KmsSigner) Sign(ctx context.Context, message []byte) ([]byte, error) {
181181 maxAttempts := maxRetries + 1
182182
183183 for attempt := 0 ; attempt < maxAttempts ; attempt ++ {
184+ if err := ctx .Err (); err != nil {
185+ return nil , err
186+ }
184187 if attempt > 0 {
185188 // Exponential backoff with cap: 100ms, 200ms, 400ms, ... up to 5s.
186189 backoff := retryBackoff (attempt )
@@ -203,7 +206,7 @@ func (s *KmsSigner) Sign(ctx context.Context, message []byte) ([]byte, error) {
203206 if err != nil {
204207 lastErr = err
205208 if ! isRetryableKMSError (err ) {
206- return nil , fmt .Errorf ("KMS Sign failed with non-retryable error: %w" , err )
209+ return nil , fmt .Errorf ("GCP KMS sign failed with non-retryable error: %w" , err )
207210 }
208211 continue
209212 }
@@ -279,8 +282,9 @@ func (s *KmsSigner) GetAddress() ([]byte, error) {
279282 if s .address == nil {
280283 return nil , fmt .Errorf ("address not loaded" )
281284 }
282-
283- return s .address , nil
285+ r := make ([]byte , len (s .address ))
286+ copy (r , s .address )
287+ return r , nil
284288}
285289
286290func isRetryableKMSError (err error ) bool {
0 commit comments