Unable to load PFX certificate with tlsOptions + workers
See original GitHub issueExample config -
const instance = autocannon({ url: 'https://localhost:8080', connection: 10, workers: 3, tlsOptions: { pfx: fs.readFileSync('path/of/p12/keystore') passphrase: 'test' } }
When I use this config. I get ‘Error: Unable to load PFX certificate’
This config works when I don’t use ‘workers’ option.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
"Error: Unable to load PFX certificate" in version 15.4 ... - GitHub
When upgrading an application to Node 16, we got problems connecting to an Elasticsearch cluster (created using a k8s operator on Azure).
Read more >Unable to load PFX certificate' on a Node Js application while ...
I am getting the below error stack trace while querying the elastic from NodeJs app. Error: Unable to load PFX certificate at ...
Read more >problem loading .pfx certificate - Microsoft Q&A
I can't load the certificates. 251639-image.png. I tried a thousand ways but it doesn't work. I generate the certificate as follows:
Read more >TLS (SSL) | Node.js v19.3.0 Documentation
Once the certificate is generated, it can be used to generate a .pfx or ... To reuse sessions across load balancers or cluster...
Read more >"unable to load certificates" when using openssl to generate a ...
Getting the error unable to load certificates means that you've chosen the wrong option when doing a 'Copy to File.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry for being late to add this but I found a workaround until the problem is fixed.
tlsOptions: { cert: fs.readFileSync('path/of/cert/in/pem/format').toString('utf8'), key: fs.readFileSync('path/of/key/in/pem/format').toString('utf8') }
so P12 keystore can be converted to PEM format cert and key which can be supplied to tlsOptions option.
@mcollina While the approach, you mentioned, will work in this use case and will solve the problem, unfortunately it will not work in other cases when there might be some options/configs that are functions.
I’ve tried your proposed solution:
but the tests are failing.
The reason that this approach (called “The structured clone algorithm”) will not work (and the reason why tests fail) is that the Function objects can’t be duplicated. See the MDN docs explaining this.
I think the best option would be to just use
lodash.clonedeep
. What do you think?