-
-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to load PFX certificate with tlsOptions + workers #391
Comments
Good spot! There has to be some issues problem when sending the certificate over to the worker. Would you like to send a Pull Request to address this issue? Remember to add unit tests. |
@mcollina I took some time to investigate this issue and the problem is not with sending the certificate to the worker, that works fine. Problem is with the certificate being, incorrectly, converted from a typed array The clone library has an open issue about this, but there has been no activity on it, since it was opened in 2016. What do you think, should we replace the library with something like lodash.clonedeep? I've tested with two approaches:
They both work - however, with |
Sorry for being late to add this but I found a workaround until the problem is fixed.
so P12 keystore can be converted to PEM format cert and key which can be supplied to tlsOptions option. |
I think we can use the v8 serializer/deserializer combo: https://nodejs.org/dist/latest-v16.x/docs/api/v8.html#v8_v8_serialize_value. |
@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 |
go with that! |
@mcollina & @gpathak18 I've created a PR, please review when you have time. Thanks. |
* Replaced 'clone' library with 'lodash.clonedeep' #391 * Removed wrong pkcs12 file * Added the right pkcs12 file * Fixed a typo in the hostname for the secure connection
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.
The text was updated successfully, but these errors were encountered: