Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: add amazon kms and benchmark signers #4168

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pleasew8t
Copy link
Contributor

Amazon KMS Guardian Signer

This PR adds an Amazon AWS KMS Guardian signer, allowing observations to be signed using KMS! The new signer can be used by specifying the ARN of the KMS key to use, through the --guardianSignerUri commandline argument, as follows:

  • --guardianSignerUri=amazonkms://<ARN>

NOTE For the best possible performance, it is recommended that the Guardian be run from an EC2 instance that is in the same region as the KMS key.

The KMS key's spec should be ECC_SECG_P256K1, and should be enabled for signing. In order for the Guardian to authenticate against the KMS service, one of two options are available:

  • Create new API keys in the AWS console that are permissioned to use the KMS key for signing, and add the keys to the EC2 instance's ~/.aws/credentials file. (example here).
  • Create a role that is permissioned to use the KMS key and attach that role to the Guardian EC2 instance.

Benchmark Signer

The PR also includes a benchmark signer, which wraps any other signer, logging signing and verification latency to prometheus histograms. External signing services might at times introduce unwanted latency, and if an event occurs where observation processing is particularly slow, the histograms would provide insight into whether or not the signing service is to blame.

NOTE
This is a redo of a previous pull request, which Pires spent time looking at. Below are key points following that review that informs the current state of the code:

  • Contexts should be supplied to signing, verification and public key retrieval, as these functions potentially interact with 3rd party services that could timeout or block indefinitely.
  • The GuardianSigner constructor (NewGuardianSignerFromUri) accepts a Context, as the new signer might need to interact with the 3rd party service to validate configurations (such as the AmazonKms signer). A different approach could be to have the constructor define its own context, to avoid the necessity of passing a context to it.

}
}

func (b *BenchmarkSigner) Sign(ctx context.Context, hash []byte) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will errors skew the data? Should you add a metric for errors and bucket the latency separately or exclude them from the latency numbers?


amazonKmsSigner := AmazonKms{
keyId: keyPath,
region: getRegionFromArn(keyPath),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: region: region,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants