Skip to content

Commit

Permalink
perf: support "skip insecure verify" and "sni" for SSL #67 #113
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-craft committed Jan 10, 2024
1 parent d989cdd commit 5d2080a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
7 changes: 2 additions & 5 deletions backend/services/connection_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,11 @@ func (c *connectionService) buildOption(config types.ConnectionConfig) (*redis.O
caCertPool.AppendCertsFromPEM(ca)
}

if len(certs) <= 0 {
return nil, errors.New("tls config error")
}

tlsConfig = &tls.Config{
RootCAs: caCertPool,
InsecureSkipVerify: false,
InsecureSkipVerify: config.SSL.AllowInsecure,
Certificates: certs,
ServerName: strings.TrimSpace(config.SSL.SNI),
}
}

Expand Down
10 changes: 6 additions & 4 deletions backend/types/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ type ConnectionDB struct {
}

type ConnectionSSL struct {
Enable bool `json:"enable,omitempty" yaml:"enable,omitempty"`
KeyFile string `json:"keyFile,omitempty" yaml:"keyFile,omitempty"`
CertFile string `json:"certFile,omitempty" yaml:"certFile,omitempty"`
CAFile string `json:"caFile,omitempty" yaml:"caFile,omitempty"`
Enable bool `json:"enable,omitempty" yaml:"enable,omitempty"`
KeyFile string `json:"keyFile,omitempty" yaml:"keyFile,omitempty"`
CertFile string `json:"certFile,omitempty" yaml:"certFile,omitempty"`
CAFile string `json:"caFile,omitempty" yaml:"caFile,omitempty"`
AllowInsecure bool `json:"allowInsecure,omitempty" yaml:"allowInsecure,omitempty"`
SNI string `json:"sni,omitempty" yaml:"sni,omitempty"`
}

type ConnectionSSH struct {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/common/FileOpenInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const handleSelectFile = async () => {
const path = get(data, 'path', '')
emit('update:value', path)
} else {
emit('update:value', '')
// emit('update:value', '')
}
}
</script>
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/components/dialogs/ConnectionDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ const onClose = () => {
:disabled="!generalForm.ssl.enable"
:placeholder="$t('dialogue.connection.ssl.ca_file_tip')" />
</n-form-item>
<n-form-item>
<n-checkbox v-model:checked="generalForm.ssl.allowInsecure" size="medium">
{{ $t('dialogue.connection.ssl.allow_insecure') }}
</n-checkbox>
</n-form-item>
<n-form-item :label="$t('dialogue.connection.ssl.sni')">
<n-input
v-model:value="generalForm.ssl.sni"
:placeholder="$t('dialogue.connection.ssl.sni')" />
</n-form-item>
</n-form>
</n-tab-pane>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/langs/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@
"ssl": {
"title": "SSL/TLS",
"enable": "Enable SSL/TLS",
"allow_insecure": "Allow Insecure Connection",
"sni": "Server Name(SNI)",
"sni_tip": "(Optional) Server Name",
"cert_file": "Public Key",
"key_file": "Private Key",
"ca_file": "Authority",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/langs/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@
"ssl": {
"title": "SSL/TLS",
"enable": "启用SSL",
"allow_insecure": "允许不安全连接",
"sni": "服务器名(SNI)",
"sni_tip": "(可选)服务器名",
"cert_file": "公钥文件",
"key_file": "私钥文件",
"ca_file": "授权文件",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/stores/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ const useConnectionStore = defineStore('connections', {
markColor: '',
ssl: {
enable: false,
allowInsecure: true,
sni: '',
certFile: '',
keyFile: '',
caFile: '',
Expand Down

0 comments on commit 5d2080a

Please sign in to comment.