MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / getPublicKey

Function getPublicKey

kms/getPublicKey.js:48–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46 );
47
48 async function getPublicKey() {
49 const [publicKey] = await client.getPublicKey({
50 name: versionName,
51 });
52
53 // Optional, but recommended: perform integrity verification on publicKey.
54 // For more details on ensuring E2E in-transit integrity to and from Cloud KMS visit:
55 // https://cloud.google.com/kms/docs/data-integrity-guidelines
56 const crc32c = require('fast-crc32c');
57 if (publicKey.name !== versionName) {
58 throw new Error('GetPublicKey: request corrupted in-transit');
59 }
60 if (crc32c.calculate(publicKey.pem) !== Number(publicKey.pemCrc32c.value)) {
61 throw new Error('GetPublicKey: response corrupted in-transit');
62 }
63
64 console.log(`Public key pem: ${publicKey.pem}`);
65
66 return publicKey;
67 }
68
69 return getPublicKey();
70 // [END kms_get_public_key]

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected