perf: 增加DB_USE_SSL配置和redis配置统一

pull/9120/head
jiangweidong 2022-11-24 16:01:26 +08:00
parent 3dde2a44e8
commit 69d8dc4bb3
2 changed files with 4 additions and 4 deletions

View File

@ -195,6 +195,7 @@ class Config(dict):
'DB_PORT': 3306,
'DB_USER': 'root',
'DB_PASSWORD': '',
'DB_USE_SSL': False,
'REDIS_HOST': '127.0.0.1',
'REDIS_PORT': 6379,
'REDIS_PASSWORD': '',

View File

@ -198,13 +198,12 @@ DATABASES = {
}
}
DB_CA_PATH = os.path.join(CERTS_DIR, 'db_ca.pem')
DB_USE_SSL = False
DB_USE_SSL = CONFIG.DB_USE_SSL
if CONFIG.DB_ENGINE.lower() == 'mysql':
DB_OPTIONS['init_command'] = "SET sql_mode='STRICT_TRANS_TABLES'"
if os.path.isfile(DB_CA_PATH):
if DB_USE_SSL:
DB_CA_PATH = exist_or_default(os.path.join(CERTS_DIR, 'db_ca.pem'), None)
DB_OPTIONS['ssl'] = {'ca': DB_CA_PATH}
DB_USE_SSL = True
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators