Skip to content
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

config requires all parameters, including key and cert params #113

Open
theprojectsomething opened this issue Mar 29, 2023 · 3 comments
Open

Comments

@theprojectsomething
Copy link

Using a config.json (per the instructions) fails where all details aren't provided, e.g:

{
  "My proxy": {
    "source": 3001,
    "target": 3000
  },
  "Another proxy": {
    "source": 9999,
    "target": 9000
  }
}

throws an error:

node:internal/fs/utils:671
    throw new ERR_INVALID_ARG_TYPE(propName, ['string', 'Buffer', 'URL'], path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.openSync (node:fs:577:10)
    at Object.readFileSync (node:fs:453:35)
    at Object.<anonymous> (node_modules/local-ssl-proxy/build/main.js:25:31)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'ERR_INVALID_ARG_TYPE'

Providing an SSL cert runs the proxy, but with undefined for the host:

Started My Proxy: https://undefined:3001 → http://undefined:3000
@nick-cromwell
Copy link

I fixed this by including all parameters in config and making a cert using mkcert.

    "Host": {
        "source": 8080,
        "target": 8081,
        "key": "localhost-key.pem",
        "cert": "localhost.pem",
        "hostname": "localhost"
    }

@momotofu
Copy link

For more context, the following error is caused by passing null as a first argument to fs.readFileSync here: https://github.com/cameronhunter/local-ssl-proxy/blob/main/src/main.ts#L24

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or...

@theprojectsomething
Copy link
Author

Thanks @momotofu that's right. Tho I think the actual issue is that the parse method in .lib isn't returning sane defaults as expected.

Explicitly defining all the config params resolves the the issue. Using a locally issued cert is ideal, but if you're not worried about MITM then the cert provided with the package will also suffice (this is what the parse method is attempting to do).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants