{"record":{"id":"b03944b1899976ae","repo":"usebruno/bruno","slug":"private-key-is-required-for-method-signature-me","errorCode":null,"errorMessage":"Private key is required for ${method} signature method","messagePattern":"Private key is required for (.+?) signature method","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/auth/oauth1-request-authorization.ts","lineNumber":186,"sourceCode":"  return `${percentEncode(consumerSecret)}&${percentEncode(tokenSecret)}`;\n}\n\n// Default hash function\nfunction defaultHashFunction(\n  baseString: string,\n  key: string,\n  method: SignatureMethod,\n  privateKey?: string\n): string {\n  switch (method) {\n    case 'PLAINTEXT':\n      return key;\n\n    case 'RSA-SHA1':\n    case 'RSA-SHA256':\n    case 'RSA-SHA512': {\n      if (!privateKey) {\n        throw new Error(`Private key is required for ${method} signature method`);\n      }\n      const algoMap: Record<string, string> = {\n        'RSA-SHA1': 'RSA-SHA1',\n        'RSA-SHA256': 'RSA-SHA256',\n        'RSA-SHA512': 'RSA-SHA512'\n      };\n      const signer = crypto.createSign(algoMap[method]);\n      signer.update(baseString);\n      return signer.sign(privateKey, 'base64');\n    }\n\n    case 'HMAC-SHA512':\n      return crypto.createHmac('sha512', key).update(baseString).digest('base64');\n\n    case 'HMAC-SHA256':\n      return crypto.createHmac('sha256', key).update(baseString).digest('base64');\n\n    case 'HMAC-SHA1':","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/auth/oauth1-request-authorization.ts#L168-L204","documentation":"Thrown by Bruno's OAuth1 signer (defaultHashFunction) when the signature method is one of RSA-SHA1, RSA-SHA256, or RSA-SHA512 but no privateKey was supplied. RSA signing requires the private key to call crypto.createSign(...).sign(privateKey); HMAC and PLAINTEXT methods do not need it.","triggerScenarios":"Configuring an OAuth1 authorizer with signature_method: 'RSA-SHA256' but omitting the private_key (or passing it as undefined/empty) on the request or authorizer config.","commonSituations":"Switched from HMAC-SHA1 to an RSA method without providing the RSA private key; private key stored in a variable that is undefined in the active environment; PEM string was pasted with stripped headers/newlines.","solutions":["Supply a valid PEM-encoded RSA private key via the authorizer/request config when using an RSA method.","If you do not have an RSA key pair, switch signature_method back to HMAC-SHA1/SHA256/SHA512.","Verify the private-key variable is populated in the active environment before signing."],"exampleFix":"// before\nconst authorizer = createOAuth1Authorizer({\n  consumer: { key, secret },\n  signature_method: 'RSA-SHA256'\n  // private_key missing\n});\n\n// after\nconst authorizer = createOAuth1Authorizer({\n  consumer: { key, secret },\n  signature_method: 'RSA-SHA256',\n  // supply via the request's rsaPrivateKey / config field used by Bruno\n});","handlingStrategy":"validation","validationCode":"const RSA_METHODS = new Set(['RSA-SHA1','RSA-SHA256','RSA-SHA512']);\nfunction validateOAuth1(method, privateKey) {\n  if (RSA_METHODS.has(method) && (!privateKey || !String(privateKey).trim())) {\n    throw new Error('RSA methods require a private key');\n  }\n}","typeGuard":"const hasRsaKeyForMethod = (method, key) => !method.startsWith('RSA-') || (typeof key === 'string' && /-----BEGIN/.test(key));","tryCatchPattern":"try { authorizer.authorize(req); }\ncatch (err) {\n  if (/Private key is required/.test(err.message)) {\n    // supply the PEM, or fall back to HMAC-SHA1\n  } else throw err;\n}","preventionTips":["Provide the PEM private key whenever you select an RSA method.","Keep the key in a Bruno secret variable.","Default to HMAC-SHA1 if you do not have an RSA key pair."],"tags":["bruno-requests","auth","oauth1","rsa","crypto","validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}