@@ -4,6 +4,7 @@ import { getAuthenticatedUser } from "coder/site/src/api/api"
44import fs from "fs"
55import * as https from "https"
66import * as module from "module"
7+ import * as os from "os"
78import * as vscode from "vscode"
89import { Commands } from "./commands"
910import { CertificateError } from "./error"
@@ -31,16 +32,22 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
3132 false ,
3233 )
3334
35+ // expandPath will expand ${userHome} in the input string.
36+ const expandPath = ( input : string ) : string => {
37+ const userHome = os . homedir ( )
38+ return input . replace ( / \$ { userHome} / g, userHome )
39+ }
40+
3441 // applyHttpProperties is called on extension activation and when the
3542 // insecure or TLS setting are changed. It updates the https agent to allow
3643 // self-signed certificates if the insecure setting is true, as well as
3744 // adding cert/key/ca properties for TLS.
3845 const applyHttpProperties = ( ) => {
3946 const cfg = vscode . workspace . getConfiguration ( )
4047 const insecure = Boolean ( cfg . get ( "coder.insecure" ) )
41- const certFile = String ( cfg . get ( "coder.tlsCertFile" ) ?? "" ) . trim ( )
42- const keyFile = String ( cfg . get ( "coder.tlsKeyFile" ) ?? "" ) . trim ( )
43- const caFile = String ( cfg . get ( "coder.tlsCaFile" ) ?? "" ) . trim ( )
48+ const certFile = expandPath ( String ( cfg . get ( "coder.tlsCertFile" ) ?? "" ) . trim ( ) )
49+ const keyFile = expandPath ( String ( cfg . get ( "coder.tlsKeyFile" ) ?? "" ) . trim ( ) )
50+ const caFile = expandPath ( String ( cfg . get ( "coder.tlsCaFile" ) ?? "" ) . trim ( ) )
4451
4552 axios . defaults . httpsAgent = new https . Agent ( {
4653 cert : certFile === "" ? undefined : fs . readFileSync ( certFile ) ,
0 commit comments