Skip to content

Commit a8ee72b

Browse files
authored
fix: set check_hostname only when credentials provided (#2231)
1 parent a50b619 commit a8ee72b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • svc-mysql/svc_mysql/vendor

svc-mysql/svc_mysql/vendor/tls.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ def get_django_ssl_options(self) -> Dict[str, str]:
6060
"""Get Django SSL options"""
6161
# 重新构造以避免修改原始配置
6262
opts = {k: v for k, v in self.tmp_cert_filepaths.items() if k in ["ca", "cert", "key"]}
63-
# 允许关闭主机名检查,因为证书可能不是由权威机构颁发的
64-
opts["check_hostname"] = self.tls_cfg.get("check_hostname", False)
63+
# 允许关闭主机名检查,因为证书可能不是由权威机构颁发的(仅当有任意证书时需要)
64+
if opts:
65+
opts["check_hostname"] = self.tls_cfg.get("check_hostname", False)
66+
6567
return opts
6668

6769
@staticmethod

0 commit comments

Comments
 (0)