Skip to content

Commit

Permalink
fix(backend): support connect to tidb without ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
wd0517 committed Aug 13, 2024
1 parent beea8a0 commit 4328623
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion backend/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def server_host(self) -> str:
TIDB_USER: str
TIDB_PASSWORD: str
TIDB_DATABASE: str
TIDB_SSL: bool = True

CELERY_BROKER_URL: str = "redis://redis:6379/0"
CELERY_RESULT_BACKEND: str = "redis://redis:6379/0"
Expand All @@ -93,7 +94,9 @@ def SQLALCHEMY_DATABASE_URI(self) -> MySQLDsn:
host=self.TIDB_HOST,
port=self.TIDB_PORT,
path=self.TIDB_DATABASE,
query="ssl_verify_cert=true&ssl_verify_identity=true",
query="ssl_verify_cert=true&ssl_verify_identity=true"
if self.TIDB_SSL
else None,
)

@computed_field # type: ignore[misc]
Expand Down
4 changes: 3 additions & 1 deletion backend/app/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def get_ssl_context():
# seems config ssl in url is not working
# we can only config ssl in connect_args
"ssl": get_ssl_context(),
},
}
if settings.TIDB_SSL
else {},
)


Expand Down

0 comments on commit 4328623

Please sign in to comment.