Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ce86ea

Browse files
corybcode-asher
authored andcommitted
feat: add options to support client tls
adding configuration properties: coder.tlsCertFile coder.tlsKeyFile coder.tlsCaFile
1 parent1fe34ab commit0ce86ea

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

‎package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@
6262
"markdownDescription":"An external command that outputs additional HTTP headers added to all requests. The command must output each header as `key=value` on its own line. The following environment variables will be available to the process: `CODER_URL`.",
6363
"type":"string",
6464
"default":""
65+
},
66+
"coder.tlsCertFile": {
67+
"markdownDescription":"Path to file for TLS client cert",
68+
"type":"string",
69+
"default":""
70+
},
71+
"coder.tlsKeyFile": {
72+
"markdownDescription":"Path to file for TLS client key",
73+
"type":"string",
74+
"default":""
75+
},
76+
"coder.tlsCaFile": {
77+
"markdownDescription":"Path to file for TLS certificate authority",
78+
"type":"string",
79+
"default":""
6580
}
6681
}
6782
},

‎src/extension.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict"
22
importaxiosfrom"axios"
33
import{getAuthenticatedUser}from"coder/site/src/api/api"
4+
importfsfrom"fs"
45
import*ashttpsfrom"https"
56
import*asmodulefrom"module"
67
import*asvscodefrom"vscode"
@@ -30,13 +31,21 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
3031
false,
3132
)
3233

33-
// updateInsecure is called on extension activation and when the insecure
34-
// setting is changed. It updates the https agent to allow self-signed
35-
// certificates if the insecure setting is true.
36-
constapplyInsecure=()=>{
37-
constinsecure=Boolean(vscode.workspace.getConfiguration().get("coder.insecure"))
34+
// applyHttpProperties is called on extension activation and when the
35+
// insecure or TLS setting are changed. It updates the https agent to allow
36+
// self-signed certificates if the insecure setting is true, as well as
37+
// adding cert/key/ca properties for TLS.
38+
constapplyHttpProperties=()=>{
39+
constcfg=vscode.workspace.getConfiguration()
40+
constinsecure=Boolean(cfg.get("coder.insecure"))
41+
constcertFile=String(cfg.get("coder.tlsCertFile"))
42+
constkeyFile=String(cfg.get("coder.tlsKeyFile"))
43+
constcaFile=String(cfg.get("coder.tlsCaFile"))
3844

3945
axios.defaults.httpsAgent=newhttps.Agent({
46+
cert:certFile==="" ?undefined :fs.readFileSync(certFile),
47+
key:keyFile==="" ?undefined :fs.readFileSync(keyFile),
48+
ca:caFile==="" ?undefined :fs.readFileSync(caFile),
4049
// rejectUnauthorized defaults to true, so we need to explicitly set it to false
4150
// if we want to allow self-signed certificates.
4251
rejectUnauthorized:!insecure,
@@ -51,9 +60,16 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
5160
)
5261

5362
vscode.workspace.onDidChangeConfiguration((e)=>{
54-
e.affectsConfiguration("coder.insecure")&&applyInsecure()
63+
if(
64+
e.affectsConfiguration("coder.insecure")||
65+
e.affectsConfiguration("coder.tlsCertFile")||
66+
e.affectsConfiguration("coder.tlsKeyFile")||
67+
e.affectsConfiguration("coder.tlsCaFile")
68+
){
69+
applyHttpProperties()
70+
}
5571
})
56-
applyInsecure()
72+
applyHttpProperties()
5773

5874
constoutput=vscode.window.createOutputChannel("Coder")
5975
conststorage=newStorage(output,ctx.globalState,ctx.secrets,ctx.globalStorageUri,ctx.logUri)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp