Can't sign data - example on documentation doesn't work
See original GitHub issue- Package Name: @azure/keyvault-keys
- Package Version: 4.0.4/4.1.0
- Operating system: Ubuntu 20.04.1
- [x ] nodejs
- version: 10.16.3
- browser
- name/version:
- typescript
- version:
- Is the bug related to documentation in
- README.md
- source code documentation
- [ x ] SDK API docs on https://docs.microsoft.com
Describe the bug Tried the example at https://docs.microsoft.com/en-us/javascript/api/overview/azure/keyvault-keys-readme?view=azure-node-latest#sign-data but keep getting this error:
(node:43146) UnhandledPromiseRejectionWarning: RestError: Invalid length of 'value': 10 bytes. RS256 requires 32 bytes, encoded with base64url. at new RestError (/home/andre/projects/eth/carbon-registry/api/functions/node_modules/@azure/core-http/dist/index.js:2344:28) at /home/andre/projects/eth/carbon-registry/api/functions/node_modules/@azure/core-http/dist/index.js:3137:25 at process._tickCallback (internal/process/next_tick.js:68:7)
To Reproduce
Steps to reproduce the behavior:
- Create a script with the example: `const { ClientSecretCredential } = require(“@azure/identity”) const { KeyClient, CryptographyClient } = require(“@azure/keyvault-keys”);
const credential = new ClientSecretCredential( configs.tenant_id, configs.client_id, configs.secret )
const vaultName = configs.name;
const url = https://${vaultName}.vault.azure.net
;
const keysClient = new KeyClient(url, credential);
async function main() { let myKey = await keysClient.createKey(“MyKey”, “RSA”); const cryptographyClient = new CryptographyClient(myKey.id, credential);
const signResult = await cryptographyClient.sign(“RS256”, Buffer.from(“My Message”)); console.log("sign result: ", signResult.result); }
main();`
Expected behavior It should log the signing result
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Hi, Daniel, thanks for taking the time to respond my inquiry.
I read you suggestion, but I still have doubts… Do you mean I can only sign strings with 32 bytes exactly? The method also throws an error for string greater than 32 bytes.
Regards,
André Meirelles
Em seg, 23 de nov de 2020 20:26, Daniel Rodríguez notifications@github.com escreveu:
@afmeirelles that is correct! sign() expects a fixed size based on the algorithm, and signData() allows you to have buffers of variable size! If that helps, I’ll make sure our docs are updated! Let me know if I can help with anything else.