Skip to content

add configuration options to support mtls #126

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

Closed
coryb opened this issue Aug 21, 2023 · 0 comments · Fixed by #128
Closed

add configuration options to support mtls #126

coryb opened this issue Aug 21, 2023 · 0 comments · Fixed by #128

Comments

@coryb
Copy link
Contributor

coryb commented Aug 21, 2023

This is related to coder/coder#8889

We run the coder api behind a TLS proxy and would like to be able to specify the client cert/key on the vscode plugin requests.

It appears we just need to add cert and key options to the axios default client:
https://github.com/coder/vscode-coder/blob/main/src/extension.ts#L39-L43

I hacked on the plugin a bit it seems these were the only changes necessary:

  const applyInsecure = () => {
    const cfg = vscode.workspace.getConfiguration()
    const insecure = Boolean(cfg.get("coder.insecure"))
    const certFile = String(cfg.get("coder.certFile"))
    const keyFile = String(cfg.get("coder.keyFile"))
    const caFile = String(cfg.get("coder.caFile"))

    axios.defaults.httpsAgent = new https.Agent({
      cert: certFile === "" ? undefined : fs.readFileSync(certFile),
      key: keyFile === "" ? undefined : fs.readFileSync(keyFile),
      ca: caFile === "" ? undefined : fs.readFileSync(caFile),
      // rejectUnauthorized defaults to true, so we need to explicitly set it to false
      // if we want to allow self-signed certificates.
      rejectUnauthorized: !insecure,
    })
  }

I know little typescript, so there is likely a better way to do it, and we would likely want to change the applyInsecure name for the expanded scope.

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

Successfully merging a pull request may close this issue.

1 participant