Skip to content

Commit 69629ca

Browse files
authored
Merge commit from fork
fix(tls): harden defaults and warn on insecure mode
2 parents 42fce72 + 66a52b8 commit 69629ca

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

drivers/webdav/meta.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ type Addition struct {
1111
Username string `json:"username" required:"true"`
1212
Password string `json:"password" required:"true"`
1313
driver.RootPath
14-
TlsInsecureSkipVerify bool `json:"tls_insecure_skip_verify" default:"false"`
1514
}
1615

1716
var config = driver.Config{

drivers/webdav/util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http/cookiejar"
77

88
"github.com/alist-org/alist/v3/drivers/webdav/odrvcookie"
9+
"github.com/alist-org/alist/v3/internal/conf"
910
"github.com/alist-org/alist/v3/internal/model"
1011
"github.com/alist-org/alist/v3/pkg/gowebdav"
1112
)
@@ -20,7 +21,7 @@ func (d *WebDav) setClient() error {
2021
c := gowebdav.NewClient(d.Address, d.Username, d.Password)
2122
c.SetTransport(&http.Transport{
2223
Proxy: http.ProxyFromEnvironment,
23-
TLSClientConfig: &tls.Config{InsecureSkipVerify: d.TlsInsecureSkipVerify},
24+
TLSClientConfig: &tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify},
2425
})
2526
if d.isSharepoint() {
2627
cookie, err := odrvcookie.GetCookie(d.Username, d.Password, d.Address)

internal/bootstrap/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ func InitConfig() {
7070
if !conf.Conf.Force {
7171
confFromEnv()
7272
}
73+
if conf.Conf.TlsInsecureSkipVerify {
74+
log.Warn("SECURITY WARNING / 安全警告:")
75+
log.Warn("TLS certificate verification is disabled.")
76+
log.Warn("TLS 证书校验已被禁用。")
77+
log.Warn("This exposes all storage traffic to MitM attacks and may leak credentials or allow data tampering.")
78+
log.Warn("这会使所有存储通信暴露于中间人攻击(MitM),可能导致凭据泄露和数据被篡改。")
79+
log.Warn("Only use this setting if you fully understand the risks.")
80+
log.Warn("仅在你完全理解风险的情况下使用该配置。")
81+
}
7382
// convert abs path
7483
if !filepath.IsAbs(conf.Conf.TempDir) {
7584
absPath, err := filepath.Abs(conf.Conf.TempDir)

internal/conf/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func DefaultConfig() *Config {
156156
},
157157
MaxConnections: 0,
158158
MaxConcurrency: 64,
159-
TlsInsecureSkipVerify: true,
159+
TlsInsecureSkipVerify: false,
160160
Tasks: TasksConfig{
161161
Download: TaskConfig{
162162
Workers: 5,

server/handles/ldap_login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func dial(ldapServer string) (*ldap.Conn, error) {
150150
}
151151

152152
if tlsEnabled {
153-
return ldap.DialTLS("tcp", ldapServer, &tls.Config{InsecureSkipVerify: true})
153+
return ldap.DialTLS("tcp", ldapServer, &tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify})
154154
} else {
155155
return ldap.Dial("tcp", ldapServer)
156156
}

0 commit comments

Comments
 (0)