feat: Database SSL one way support (#33044)

* feat: Support one-way SSL authentication for database connections

Updated MariaDB database connection to support one-way SSL authentication

* feat(database): Add support for MySQLClient one-way SSL connections

* feat: Format and pre-commit

* fix: Default option for hostname check

* chore: simplify

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Prafful S 2025-07-16 12:06:19 +05:30 committed by GitHub
parent ba298488c5
commit bd4fc118e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 8 deletions

View file

@ -142,12 +142,19 @@ class MariaDBConnectionUtil:
if frappe.conf.local_infile:
conn_settings["local_infile"] = frappe.conf.local_infile
if frappe.conf.db_ssl_ca and frappe.conf.db_ssl_cert and frappe.conf.db_ssl_key:
conn_settings["ssl"] = {
# Configure SSL settings
if frappe.conf.db_ssl_ca:
ssl_config = {
"ca": frappe.conf.db_ssl_ca,
"cert": frappe.conf.db_ssl_cert,
"key": frappe.conf.db_ssl_key,
"check_hostname": frappe.conf.db_ssl_check_hostname,
}
# Add client certificates for mutual SSL if available
if frappe.conf.db_ssl_cert and frappe.conf.db_ssl_key:
ssl_config.update({"cert": frappe.conf.db_ssl_cert, "key": frappe.conf.db_ssl_key})
conn_settings["ssl"] = ssl_config
return conn_settings

View file

@ -143,13 +143,19 @@ class MariaDBConnectionUtil:
if frappe.conf.local_infile:
conn_settings["local_infile"] = frappe.conf.local_infile
if frappe.conf.db_ssl_ca and frappe.conf.db_ssl_cert and frappe.conf.db_ssl_key:
conn_settings["ssl"] = {
# Configure SSL settings
if frappe.conf.db_ssl_ca:
ssl_config = {
"ca": frappe.conf.db_ssl_ca,
"cert": frappe.conf.db_ssl_cert,
"key": frappe.conf.db_ssl_key,
"check_hostname": frappe.conf.db_ssl_check_hostname,
}
# Add client certificates for mutual SSL if available
if frappe.conf.db_ssl_cert and frappe.conf.db_ssl_key:
ssl_config.update({"cert": frappe.conf.db_ssl_cert, "key": frappe.conf.db_ssl_key})
conn_settings["ssl"] = ssl_config
return conn_settings