File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
iothub/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ public final class ClientConfiguration
46
46
47
47
private static final long DEFAULT_OPERATION_TIMEOUT = 4 * 60 * 1000 ; //4 minutes
48
48
49
+ private static final long MAX_SAS_TOKEN_EXPIRY_TIME_SECONDS = 10 * 365 * 24 * 60 * 60 ; //10 years
50
+
49
51
private boolean useWebsocket ;
50
52
51
53
@ Getter
@@ -244,6 +246,13 @@ private void setClientOptionValues(ClientOptions clientOptions)
244
246
throw new IllegalArgumentException ("ClientOption sasTokenExpiryTime must be greater than 0" );
245
247
}
246
248
249
+ if (clientOptions .getSasTokenExpiryTime () >= MAX_SAS_TOKEN_EXPIRY_TIME_SECONDS )
250
+ {
251
+ // Higher values cause overflows that result in the SDK repeatedly renewing SAS tokens
252
+ // and are generally a security risk
253
+ throw new IllegalArgumentException ("ClientOption sasTokenExpiryTime must be less than 10 years" );
254
+ }
255
+
247
256
this .getSasTokenAuthentication ().setTokenValidSecs (clientOptions .getSasTokenExpiryTime ());
248
257
}
249
258
You can’t perform that action at this time.
0 commit comments