usebruno/bruno · error · Error
Error reading pfx file: ${err.message}
Error message
Error reading pfx file: ${err.message} What it means
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.
Source
Thrown at packages/bruno-requests/src/utils/http-https-agents.ts:309
keyFilePath = path.isAbsolute(keyFilePath) ? keyFilePath : path.join(collectionPath, keyFilePath);
certsConfig.cert = fs.readFileSync(certFilePath);
certsConfig.key = fs.readFileSync(keyFilePath);
} catch (err: any) {
console.error('Error reading cert/key file', err);
throw new Error(`Error reading cert/key file: ${err.message}`);
}
} else if (type === 'pfx') {
try {
let pfxFilePath = clientCert?.pfxFilePath;
if (!pfxFilePath) {
throw new Error('pfxFilePath is required for pfx type');
}
pfxFilePath = path.isAbsolute(pfxFilePath) ? pfxFilePath : path.join(collectionPath, pfxFilePath);
certsConfig.pfx = fs.readFileSync(pfxFilePath);
} catch (err: any) {
console.error('Error reading pfx file', err);
throw new Error(`Error reading pfx file: ${err.message}`);
}
}
certsConfig.passphrase = clientCert.passphrase;
break;
}
}
}
/**
* Proxy configuration
*
* Preferences proxyMode has four possible values: on, off, system, pac
* Collection proxyMode has three possible values: true, false, global
*
* When collection proxyMode is true, it overrides the app-level proxy settings
* When collection proxyMode is false, it ignores the app-level proxy settings
* When collection proxyMode is global, it uses the app-level proxy settings
*View on GitHub (pinned to 9bdd81c7bd)
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.
Example fix
// before: relative pfx path resolved against wrong dir -> 'Error reading pfx file: ENOENT'
{ type:'pfx', pfxFilePath:'certs/c.pfx' }
// after
{ type:'pfx', pfxFilePath: path.join(collectionPath,'certs','c.pfx') } Defensive patterns
Strategy: try-catch
Validate before calling
import fs from 'node:fs';
for (const cc of certs) {
if (cc.disabled || cc.type !== 'pfx') continue;
const p = cc.pfxFilePath; if (!p) continue;
const full = path.isAbsolute(p) ? p : path.join(collectionPath, p);
if (!fs.existsSync(full)) throw new Error(`pfx file not found: ${full}`);
} Try / catch
try { configurePfx(certsConfig, ...); } catch (e) { if (/Error reading pfx file/.test(e.message)) { /* disable pfx, retry */ } else throw e; } Prevention
- Inspect the suffix to distinguish required-field from ENOENT.
- Use absolute paths or paths relative to collectionPath.
When it happens
Trigger: pfxFilePath resolved to a missing/unreadable file, or the required-field guard fired (suffix would be 'pfxFilePath is required for pfx type').
Common situations: pfx file moved/deleted; relative path resolved against an unexpected collectionPath; permission denied; collection copied across machines without the cert bundle.
Related errors
- Error reading cert/key file: ${err.message}
- pfxFilePath is required for pfx type
- Unable to load custom CA certificate: ${(err as Error).messa
- Invalid custom CA certificate path: ${caCertFilePath}
- certFilePath is required for cert type
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/21b3a23adeba2b34.
Report an issue: GitHub.