forked from letsencrypt/boulder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gRPC: reject request if clock skew is too large (letsencrypt#7686)
Have our gRPC server interceptor check for excessive clock skew between its own clock and gRPC client clocks. Do this by taking advantage of the client request timestamp that most clients already supply for the purpose of measuring cross-service latency. If the included timestamp is more than 10 minutes from the gRPC server's local time, immediately error out. To keep the integration tests -- which heavily rely on clock manipulation -- working, use build tags to disable this behavior during integration testing. Fixes letsencrypt#7684
- Loading branch information
1 parent
da7865c
commit e5731a4
Showing
5 changed files
with
115 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build !integration | ||
|
||
package grpc | ||
|
||
import "time" | ||
|
||
// tooSkewed returns true if the absolute value of the input duration is more | ||
// than ten minutes. We break this out into a separate function so that it can | ||
// be disabled in the integration tests, which make extensive use of fake | ||
// clocks. | ||
func tooSkewed(skew time.Duration) bool { | ||
return skew > 10*time.Minute || skew < -10*time.Minute | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//go:build integration | ||
|
||
package grpc | ||
|
||
import "time" | ||
|
||
// tooSkewed always returns false, but is only built when the integration build | ||
// flag is set. We use this to replace the real tooSkewed function in the | ||
// integration tests, which make extensive use of fake clocks. | ||
func tooSkewed(_ time.Duration) bool { | ||
return false | ||
} |