Skip to content

Commit 8461ad2

Browse files
authored
fix: cache TES SSL certificate failures (#1720)
- SSL certificate errors (AWSIotException/TLSAuthException) now use UNKNOWN_ERROR_CACHE_IN_MIN (5 minutes) instead of immediate expiry - Prevents excessive bandwidth usage from continuous retry loops when SSL handshake fails - Maintains proper error caching behavior for connection failures This resolves an issue where SSL certificate validation failures would bypass the intended error caching mechanism, causing credential requests to retry every ~2 seconds instead of respecting the configured 5-minute cache timeout.
1 parent f6a76b6 commit 8461ad2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/com/aws/greengrass/tes/CredentialRequestHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,11 @@ private byte[] getCredentialsBypassCache() {
314314
tesCache.get(iotCredentialsPath).expiry = newExpiry;
315315
tesCache.get(iotCredentialsPath).credentials = response;
316316
} catch (AWSIotException | TLSAuthException e) {
317-
// Http connection error should expire immediately
317+
// Http connection error should be cached to avoid excessive retries
318318
String responseString = "Failed to get connection";
319319
response = responseString.getBytes(StandardCharsets.UTF_8);
320-
newExpiry = Instant.now(clock);
320+
// Use unknown error cache policy for SSL/TLS connection errors to prevent excessive retries
321+
newExpiry = Instant.now(clock).plus(Duration.ofMinutes(UNKNOWN_ERROR_CACHE_IN_MIN));
321322
tesCache.get(iotCredentialsPath).responseCode = HttpURLConnection.HTTP_INTERNAL_ERROR;
322323
tesCache.get(iotCredentialsPath).expiry = newExpiry;
323324
tesCache.get(iotCredentialsPath).credentials = response;

0 commit comments

Comments
 (0)