{"record":{"id":"21b3a23adeba2b34","repo":"usebruno/bruno","slug":"error-reading-pfx-file-err-message","errorCode":null,"errorMessage":"Error reading pfx file: ${err.message}","messagePattern":"Error reading pfx file: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/utils/http-https-agents.ts","lineNumber":309,"sourceCode":"            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) {\n            console.error('Error reading pfx file', err);\n            throw new Error(`Error reading pfx file: ${err.message}`);\n          }\n        }\n        certsConfig.passphrase = clientCert.passphrase;\n        break;\n      }\n    }\n  }\n\n  /**\n   * Proxy configuration\n   *\n   * Preferences proxyMode has four possible values: on, off, system, pac\n   * Collection proxyMode has three possible values: true, false, global\n   *\n   * When collection proxyMode is true, it overrides the app-level proxy settings\n   * When collection proxyMode is false, it ignores the app-level proxy settings\n   * When collection proxyMode is global, it uses the app-level proxy settings\n   *","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/utils/http-https-agents.ts#L291-L327","documentation":"Catch-all around the pfx loading block. Wraps fs.readFileSync failures (and the pfxFilePath-required guard) with the 'Error reading pfx file:' prefix, preserving the underlying message.","triggerScenarios":"pfxFilePath resolved to a missing/unreadable file, or the required-field guard fired (suffix would be 'pfxFilePath is required for pfx type').","commonSituations":"pfx file moved/deleted; relative path resolved against an unexpected collectionPath; permission denied; collection copied across machines without the cert bundle.","solutions":["Read the suffix to distinguish missing-config from missing-file.","Confirm pfxFilePath is absolute or correctly relative to collectionPath and readable.","Re-pick the .pfx file after relocating the collection."],"exampleFix":"// before: relative pfx path resolved against wrong dir -> 'Error reading pfx file: ENOENT'\n{ type:'pfx', pfxFilePath:'certs/c.pfx' }\n\n// after\n{ type:'pfx', pfxFilePath: path.join(collectionPath,'certs','c.pfx') }","handlingStrategy":"try-catch","validationCode":"import fs from 'node:fs';\nfor (const cc of certs) {\n  if (cc.disabled || cc.type !== 'pfx') continue;\n  const p = cc.pfxFilePath; if (!p) continue;\n  const full = path.isAbsolute(p) ? p : path.join(collectionPath, p);\n  if (!fs.existsSync(full)) throw new Error(`pfx file not found: ${full}`);\n}","typeGuard":null,"tryCatchPattern":"try { configurePfx(certsConfig, ...); } catch (e) { if (/Error reading pfx file/.test(e.message)) { /* disable pfx, retry */ } else throw e; }","preventionTips":["Inspect the suffix to distinguish required-field from ENOENT.","Use absolute paths or paths relative to collectionPath."],"tags":["tls","client-cert","pfx","filesystem","wrapper"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}