question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A lot of reading of Google Cloud KMS keyrings and keys during signing

See original GitHub issue

STR:

  1. Generate asymmetric key and CA
gcloud kms keyrings create test --location <region>```
gcloud kms keys create my-key --keyring test --location <region> --purpose "asymmetric-signing" --default-algorithm "rsa-sign-pkcs1-2048-sha256"
openssl genrsa -out ca.key 2048
  1. Create CSR and Certificate
git clone https://github.com/mattes/google-cloud-kms-csr
cd google-cloud-kms-csr
go build -o csr
./csr -key $(gcloud kms keys versions list  --key my-key --keyring test --location=<region>) -out my.csr --common-name MyOrg
openssl -req -in my.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out my.crt
  1. Run jsign
for i in {1..1000}; do 
jsign --storetype GOOGLECLOUD
  --storepass "$(gcloud auth print-access-token)"
  --keystore "projects/<project>/locations/<location>/keyRings/test"
  --alias "my-key"
  --certfile my.crt
  my.exe
done

Expected result: Binary signed

Actual result:

java.io.IOException: 429 - RESOURCE_EXHAUSTED: Quota exceeded for quota metric 'Read requests' and limit 'Read requests per minute' of service 'cloudkms.googleapis.com' for consumer 'project_number:<project-id>

screenshot-console cloud google com-2021 07 05-15_13_45

So, each run of jsign makes 2 reading and 1 crypto operation. But default quotas are:

  • Cryptographic requests per minute: 60,000
  • Read requests per minute: 300

Also jsign require a lot of permissions for one signing For key:

cloudkms.cryptoKeyVersions.list
cloudkms.cryptoKeyVersions.useToSign
cloudkms.locations.get
cloudkms.locations.list
resourcemanager.projects.get

For keyring:

cloudkms.cryptoKeys.list

Actually only one permission required cloudkms.cryptoKeyVersions.useToSign and only 2 parameters to run key.id (example: projects/<project id>/locations/<location>/keyRings/<keyring>/cryptoKeys/<key name>/cryptoKeyVersions/<version> and algorithm (example: RSA).

I have 2 suggestions:

  • Cache keys list and keys versions list between runs of jsign
  • Add ability to specify only key.id and algorithm

I will try to implement second.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ebourgcommented, Jul 6, 2021

The request to get all the keys has been removed, there is now only one request per file signed.

I’d still recommend signing multiple files with a single invocation of jsign from the command line, it should be slightly faster.

0reactions
ebourgcommented, Jul 6, 2021

Nice! Thank you for torturing testing Jsign thoroughly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quickstart: Create encryption keys with Cloud KMS
Sign in to your Google Cloud account. If you're new to Google Cloud, ... Important: This quickstart creates Cloud KMS resources such as...
Read more >
Google Cloud KMS - Secrets Engines - HTTP API | Vault
This is the API documentation for the Vault Google Cloud KMS secrets engine. ... key ( string: "" ) - Name of the...
Read more >
How to send encoded KMS keyring information in google ...
How to send KMS keyring information in encoded format in google signed URL for customer managed encryption key.
Read more >
How to secure and manage secrets using Google Cloud KMS
At runtime, we'll load encrypted files, decrypt using KMS APIs and use it. Cloud KMS is a cloud-hosted key management service that lets...
Read more >
Getting Started with Cloud KMS | Google Cloud Skills Boost
How to start your lab and sign in to the Google Cloud Console. Click the Start Lab button. ... Note: CryptoKeys and KeyRings...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found