This package provides a Node.js client to interact with the Google Distributed Cloud air-gapped (GDC) Certificate Authority Service (CAS).
cas/
├── gdc-cas/
│ ├── cas-client.js // CAS Client implementation
│ ├── cas-client.d.ts // Type information for the CAS Client
│ ├── sts-auth.js // STS Token Auth for service account implementation
│ ├── index.js // Entry point for the package
│ └── package.json // Defines the gdc-cas package
├── package.json // Defines the dependencies for run-example.js
└── run-example.js // Sample code / QPS load test to use the CAS client
For detailed package usage, prerequisites, and publishing instructions, please refer to the gdc-cas package README.
This directory includes a sample script run-example.js that demonstrates how to locally test the CAS client or run a QPS load test.
npm install(Ensure you have set up your service account JSON file, e.g., sa.json, and trust store bundle, e.g., ca.crt, as per the prerequisites in the main package README).
The script supports three execution modes:
Runs the original single-certificate lifecycle demonstration (create, show, list, and delete a single certificate request).
node run-example.js demo [flags]Runs a parallel certificate request load test issuing requests concurrently as fast as possible in multiple runs.
node run-example.js qps-burst [flags]Runs a sustained load test that dispatches a paced number of requests per second for a specified duration, reusing a pre-generated pool of CSRs to prevent client-side CPU bottlenecks.
node run-example.js qps-duration [flags]You can customize the client config and test behavior using the following flags:
| Flag | Description | Default (Demo) | Default (QPS-Burst/Duration) |
|---|---|---|---|
--sa-file <path> |
Path to the service account private key JSON file | sa.json |
sa.json |
--ca-file <path> |
Path to GDC trust store bundle | ca.crt |
ca.crt |
--zone <name> |
GDC Zone name (e.g., us-west6-a) |
zone1 |
zone1 |
--project <name> |
GCP/GDC Project/Namespace | cas-test |
cas-load-test |
--ca-name <name> |
Name of the Certificate Authority | sub-ca-1 |
root-ca-ecdsa |
--load <number> |
Total requests per run (Burst) / requests per second (Duration) | 50 |
50 |
--validity <duration> |
Certificate validity duration (e.g., 90d, 2160h, 10m) |
90d |
90d |
--runs <number> |
Total number of runs (only applicable in qps-burst mode) |
10 |
10 |
--duration <duration> |
Sustained test duration (e.g., 30s, 5m) (only applicable in qps-duration mode) |
30s |
30s |
--polling-interval <dur> |
Polling interval for KRM certificate ready check (e.g., 200ms, 1s) |
200ms |
200ms |
--clean |
Clean up CertificateRequests and RevokeCertificateRequests in the namespace before/after test | false |
false |
--rsa-key-size <number> |
RSA key size for generated certificates | 2048 |
2048 |
--use-grpc |
Use native gRPC to bypass KRM | false |
false |
--cas-proxy-url <url> |
URL for the CAS proxy if using gRPC | null |
null |
--revoke |
If true, revokes the certificate(s) after creation/issuance (supports both KRM and gRPC modes) | false |
false |
--revoke-timeout <duration> |
Timeout for KRM revocation polling (e.g., 10m, 30s) |
10m |
10m |
Run the demo mode in a custom namespace:
node run-example.js demo --sa-file staging-sa.json --ca-file staging-ca.crt --zone us-west6-a --project my-project --ca-name my-caRun a QPS burst load test with 5 runs of 10 parallel requests:
node run-example.js qps-burst --sa-file staging-sa.json --ca-file staging-ca.crt --zone us-west6-a --project my-project --ca-name my-ca --load 10 --runs 5Run a sustained QPS duration load test at a rate of 50 requests/sec for 30 seconds with a 1-second polling interval:
node run-example.js qps-duration --sa-file staging-sa.json --ca-file staging-ca.crt --zone us-west6-a --project my-project --ca-name my-ca --load 50 --duration 30s --polling-interval 1sRun a QPS burst load test using direct gRPC calls to the CAS proxy (bypassing KRM):
node run-example.js qps-burst --sa-file staging-sa.json --ca-file staging-ca.crt --zone us-west6-a --project my-project --ca-name my-ca --load 10 --runs 5 --use-grpcRun the demo mode with KRM and certificate revocation enabled:
node run-example.js demo --sa-file staging-sa.json --ca-file staging-ca.crt --zone us-west6-a --project my-project --ca-name my-ca --revokeRun the demo mode with gRPC and certificate revocation enabled:
node run-example.js demo --sa-file staging-sa.json --ca-file staging-ca.crt --zone us-west6-a --project my-project --ca-name my-ca --use-grpc --revokeRun a KRM QPS burst load test with 5 runs of 10 parallel requests, including KRM certificate revocation:
node run-example.js qps-burst --sa-file staging-sa.json --ca-file staging-ca.crt --zone us-west6-a --project my-project --ca-name my-ca --load 10 --runs 5 --revokeRun a gRPC QPS burst load test with 5 runs of 10 parallel requests, including gRPC certificate revocation:
node run-example.js qps-burst --sa-file staging-sa.json --ca-file staging-ca.crt --zone us-west6-a --project my-project --ca-name my-ca --load 10 --runs 5 --use-grpc --revokeClean up all CertificateRequests and RevokeCertificateRequests in the load test namespace:
node run-example.js qps-burst --sa-file staging-sa.json --ca-file staging-ca.crt --zone us-west6-a --project my-project --cleanFor executing the load test in ad-hoc environments without Node.js or node_modules dependencies, you can compile run-example.js into a standalone native binary:
-
Install bundler and compiler tools dynamically (without modifying
package.json):npm install --no-save --registry=https://registry.npmjs.org/ esbuild pkg
-
Bundle the script and dependencies:
./node_modules/.bin/esbuild run-example.js --bundle --platform=node --format=cjs --outfile=dist/run-example.cjs
-
Compile the bundle into a native Linux x64 binary using package.json config:
./node_modules/.bin/pkg package.json --targets node18-linux-x64 --output run-example-bin
This generates a standalone binary named run-example-bin in the project root. To transfer and run this in your target environment:
-
Compress the binary:
tar -czvf run-example-bin.tgz run-example-bin
-
Upload the compressed binary and configuration files: Transfer the archive to your target machine using
scpor your environment's file transfer tool:scp run-example-bin.tgz user@remote-host:/tmp/
-
Extract and execute the test on the remote environment:
cd /tmp tar -xzvf run-example-bin.tgz ./run-example-bin qps-burst --sa-file ~/sa.json --ca-file ca.crt --zone us-west6-a --project my-project --load 50 --runs 3