{"record":{"id":"5a8e22acb4d2580c","repo":"usebruno/bruno","slug":"keyfilepath-is-required-for-cert-type","errorCode":null,"errorMessage":"keyFilePath is required for cert type","messagePattern":"keyFilePath is required for cert type","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/utils/http-https-agents.ts","lineNumber":289,"sourceCode":"  for (const clientCert of clientCertConfig) {\n    if (clientCert?.disabled) {\n      continue;\n    }\n    const domain = clientCert?.domain;\n    const type = clientCert?.type || 'cert';\n    if (domain) {\n      const hostRegex = '^(https:\\\\/\\\\/|grpc:\\\\/\\\\/|grpcs:\\\\/\\\\/)?' + domain.replace(/\\./g, '\\\\.').replace(/\\*/g, '.*');\n      if (requestUrl && requestUrl.match(hostRegex)) {\n        if (type === 'cert') {\n          try {\n            let certFilePath = clientCert?.certFilePath;\n            if (!certFilePath) {\n              throw new Error('certFilePath is required for cert type');\n            }\n            certFilePath = path.isAbsolute(certFilePath) ? certFilePath : path.join(collectionPath, certFilePath);\n            let keyFilePath = clientCert?.keyFilePath;\n            if (!keyFilePath) {\n              throw new Error('keyFilePath is required for cert type');\n            }\n            keyFilePath = path.isAbsolute(keyFilePath) ? keyFilePath : path.join(collectionPath, keyFilePath);\n\n            certsConfig.cert = fs.readFileSync(certFilePath);\n            certsConfig.key = fs.readFileSync(keyFilePath);\n          } catch (err: any) {\n            console.error('Error reading cert/key file', err);\n            throw new Error(`Error reading cert/key file: ${err.message}`);\n          }\n        } else if (type === 'pfx') {\n          try {\n            let pfxFilePath = clientCert?.pfxFilePath;\n            if (!pfxFilePath) {\n              throw new Error('pfxFilePath is required for pfx type');\n            }\n            pfxFilePath = path.isAbsolute(pfxFilePath) ? pfxFilePath : path.join(collectionPath, pfxFilePath);\n            certsConfig.pfx = fs.readFileSync(pfxFilePath);\n          } catch (err: any) {","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/utils/http-https-agents.ts#L271-L307","documentation":"Counterpart to the cert-file guard: a type 'cert' entry requires keyFilePath to be set. Throws when certFilePath was provided but keyFilePath is falsy.","triggerScenarios":"Client-cert entry matched the request domain, type is 'cert', certFilePath present, but keyFilePath is empty/undefined.","commonSituations":"User picked the certificate but forgot the private key file; config migrated incompletely; only the public cert was supplied.","solutions":["Select a private key file for the entry in Client Certificates settings.","Populate keyFilePath alongside certFilePath in the stored config.","Disable the entry if you do not have a key yet."],"exampleFix":"// before\n{ domain:'api.example.com', type:'cert', certFilePath:'/c.pem' } // no keyFilePath\n\n// after\n{ domain:'api.example.com', type:'cert', certFilePath:'/c.pem', keyFilePath:'/k.pem' }","handlingStrategy":"validation","validationCode":"for (const cc of clientCertificates?.certs ?? []) {\n  if (!cc.disabled && cc.type !== 'pfx' && !cc.keyFilePath) throw new Error(`keyFilePath missing for domain ${cc.domain}`);\n}","typeGuard":"function isValidCertEntry(c): boolean { return c?.type === 'pfx' ? !!c.pfxFilePath : !!c?.certFilePath && !!c?.keyFilePath; }","tryCatchPattern":null,"preventionTips":["Always pair certFilePath with keyFilePath.","Re-pick files after relocating a collection."],"tags":["tls","client-cert","validation","config"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}