question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load PFX certificate with tlsOptions + workers

See original GitHub issue

Example 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:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
gpathak18commented, Oct 12, 2021

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.

1reaction
radomirdcommented, Oct 13, 2021

@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:

const cloneDeep = obj => v8.deserialize(v8.serialize(obj))

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found