--- lbbs/src/database.c 2025/11/04 13:49:51 1.18 +++ lbbs/src/database.c 2025/11/20 14:40:17 1.23 @@ -3,25 +3,32 @@ * database * - configuration and function of DB connection * - * Copyright (C) 2004-2025 by Leaflet + * Copyright (C) 2004-2025 Leaflet */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "common.h" #include "database.h" #include "log.h" +#include #include -#include +#include // Global declaration for database -char DB_host[256]; -char DB_username[50]; -char DB_password[50]; -char DB_database[50]; -char DB_timezone[50]; +char DB_ca_cert[FILE_PATH_LEN] = "conf/ca_cert.pem"; +char DB_host[DB_host_max_len + 1]; +char DB_username[DB_username_max_len + 1]; +char DB_password[DB_password_max_len + 1]; +char DB_database[DB_database_max_len + 1]; +char DB_timezone[DB_timezone_max_len + 1]; MYSQL *db_open() { MYSQL *db = NULL; + my_bool disabled = 0; char sql[SQL_BUFFER_LEN]; db = mysql_init(NULL); @@ -31,6 +38,9 @@ MYSQL *db_open() return NULL; } + mysql_ssl_set(db, NULL, NULL, DB_ca_cert, NULL, NULL); + mysql_optionsv(db, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &disabled); + if (mysql_real_connect(db, DB_host, DB_username, DB_password, DB_database, 0, NULL, 0) == NULL) {