Skip to content

Commit

Permalink
Fix trying to open undefined certs
Browse files Browse the repository at this point in the history
The issue is that cfg.get() is returning undefined, which becomes
"undefined".  Originally it was thought cfg.get() would return the
default ("") but it seems that is not always the case.

The trim is an extra addition in case the value is a string with just
whitespace.
  • Loading branch information
code-asher committed Sep 19, 2023
1 parent d8197ef commit 1af6486
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
const applyHttpProperties = () => {
const cfg = vscode.workspace.getConfiguration()
const insecure = Boolean(cfg.get("coder.insecure"))
const certFile = String(cfg.get("coder.tlsCertFile"))
const keyFile = String(cfg.get("coder.tlsKeyFile"))
const caFile = String(cfg.get("coder.tlsCaFile"))
const certFile = String(cfg.get("coder.tlsCertFile") ?? "").trim()
const keyFile = String(cfg.get("coder.tlsKeyFile") ?? "").trim()
const caFile = String(cfg.get("coder.tlsCaFile") ?? "").trim()

axios.defaults.httpsAgent = new https.Agent({
cert: certFile === "" ? undefined : fs.readFileSync(certFile),
Expand Down

0 comments on commit 1af6486

Please sign in to comment.