feat(database): support configurable SSL mode for PostgreSQL and MySQL

Add ssl_mode configuration option to allow users to customize SSL/TLS
policy for database connections instead of hardcoding sslmode=disable
for PostgreSQL and having no TLS support for MySQL.

Changes:
- database.Config, DatabaseConfig: add SSLMode field
- PostgreSQL DSN: replace hardcoded sslmode=disable with configurable
value
- MySQL DSN: append &tls=<SSLMode> parameter when SSLMode is set
- Full config pipeline: INI/env -> DatabaseConfig -> Config -> DSN ->
subprocess
- New env var BH_DB_SSL_MODE and ini key [database] ssl_mode
- Updated config example and documentation
This commit is contained in:
little-sparkleeesss
2026-06-13 23:19:03 +08:00
parent 0533fe6c9c
commit ae273d5b92
7 changed files with 46 additions and 11 deletions
+2
View File
@@ -28,6 +28,8 @@ path = data/baihu.db
dsn =
# 表前缀
table_prefix = baihu_
# SSL 模式 (仅 mysql/postgres): postgres 支持 disable/require/verify-ca/verify-full; mysql 支持 true/skip-verify
# ssl_mode = disable
[security]
# JWT 密钥。留空则在首次启动时自动生成并保存到数据库设置中。