MariaDB / QMySqlDriver connection without SSL got 2026 error
-
My problem:
A MariaDB-Server is running in a LAMPP-Installation
It runs by default without SSL!A Qt-Application (both 5.15.2 and 6.10.1) with loaded QMARIADB-Driver tried to open a connection to the server and stopped with this error message:
QSqlError("2026", "QMYSQL: Unable to connect", "TLS/SSL error: SSL is required, but the server does not support it")My aim is to connect locally WITHOUT SSL!
Installing SSL in MariaDB is no an option.MariaDB Server is in fact running well without SSL and accepts connections by phpMyAdmin.
But with QMySqlDriver in case of MariaDB (not MySQL) there is no connectOption parameter to switch off SSL on client size.According to mariadb documentation, a local connection (filesocket!) should work without enforement of SSL.
This is the disfunction in question.
The QMySqlDriver connectOption 'MYSQL_OPT_SSL_MODE' ist rejected in case of MariaDB.
The mariadb client can be switched in my.conf with:[Client] skip-ssl=trueBut that is not interpreted by QMySqlDriver, which is instructed by connectOption() parameters.
In qsql_mysql.cpp you can find:#if defined(MYSQL_VERSION_ID) && MYSQL_VERSION_ID >= 50711 && !defined(MARIADB_VERSION_ID) {"MYSQL_OPT_SSL_MODE"_L1, MYSQL_OPT_SSL_MODE, setOptionSslMode}, #endifBy this MariaDB is excluded from getting this parameter.
(1) This error appears both on 5.15.2 and 6.10.1 compilation of the Application.
(2) It appears on new LAMPP 8.2.12 (2025), NOT on old LAMPP 7.4.2 (2020)
both with MariaDB (new 10.4.32, old 10.4.11)MariaDB is able to connect locally without SSL (by phpmyadmin), QMySqlDriver is not serving this opportunity.
Has anyone experiences with or solutions to this problem?
Thanks in advance!
My context:
SuSE 16 Installation
Qt: 5.15.2 and 6.10.1New (with error):
LAMPP 8.2.12 from 11/2025- MariaDB 10.4.32
- libmariadb.so.3 (3.1.22?)
- MariaDB runs without SSL by default
- OpenSSL 1.1.1
Old (without error):
LAMPP 7.4.2-0 from 2020-01-30- Apache 2.4.41
- MariaDB 10.4.11
- OpenSSL 1.1.1d
- PHP 7.4.2
- phpMyAdmin 5.0.1
-
This is due to https://mariadb.com/docs/server/security/securing-mariadb/encryption/data-in-transit-encryption/securing-connections-for-client-and-server
You can disable the check by setting the connect optionMYSQL_OPT_SSL_VERIFY_SERVER_CERT=FALSE.
And yes, MariaDB simply does not provide theMYSQL_OPT_SSL_MODEso you can't set it in the Qt plugin either: https://github.com/mariadb-corporation/mariadb-connector-c/blob/3.4/include/mysql.h#L184 -
Hello Mister Ehrlicher!
@Christian-Ehrlicher said in MariaDB / QMySqlDriver connection without SSL got 2026 error:
You can disable the check by setting the connect option MYSQL_OPT_SSL_VERIFY_SERVER_CERT=FALSE.
This is not working:
OK! SQL Treiber: "QMYSQL" "MySQL" QMYSQLDriver::open: Illegal connect option value 'MYSQL_OPT_SSL_VERIFY_SERVER_CERT=FALSE' *** keine Verbindung: "werkbank" QSqlError("2026", "QMYSQL: Unable to connect", "TLS/SSL error: SSL is required, but the server does not support it")In qsql_mysql.cpp this parameter is not supported.
-
Qt5 is no longer supported and therefore this option is not available there. Upgrade or change your server to allow unencrypted connections.
-
Hello Mister Ehrlicher!
@Christian-Ehrlicher said in MariaDB / QMySqlDriver connection without SSL got 2026 error:
You can disable the check by setting the connect option MYSQL_OPT_SSL_VERIFY_SERVER_CERT=FALSE.
This is not working:
OK! SQL Treiber: "QMYSQL" "MySQL" QMYSQLDriver::open: Illegal connect option value 'MYSQL_OPT_SSL_VERIFY_SERVER_CERT=FALSE' *** keine Verbindung: "werkbank" QSqlError("2026", "QMYSQL: Unable to connect", "TLS/SSL error: SSL is required, but the server does not support it")In qsql_mysql.cpp this parameter is not supported.
@mediendynamik.de You're sue you cannot go with One-Way TLS for MariaDB Clients? (That way both phpMyAdnin and Qt6 clients should be able to connect.)
-
Thanks for you help!
(1) The best solution seams to be:
int main(int argc, char *argv[]) { qputenv("MARIADB_TLS_DISABLE_PEER_VERIFICATION","1"); // must be inserted before the constructor call of QCoreApplication QApplication a(argc, argv); // ... }This works for 5.(15.2) and 6.(10.1) both with minimal efforts.
(2) Adding an connectOptions() part:
MYSQL_OPT_SSL_VERIFY_SERVER_CERT = 0works only for 6.(10.1)
-
Yee, That's the reason. As above, Source code of qsqlmysql plugin only supports a few connection options from https://dev.mysqlserver.cn/doc/c-api/8.4/en/mysql-options.html . MYSQL_OPT_SSL_MODE=SSL_MODE_DISABLED can disable SSL. But this option is NOT supported with "if" blocks in qsqlmysql codes.
MYSQL_OPT_SSL_MODE=SSL_MODE_DISABLED is important because that an OLD version mysql db contains large data may be still valuable.
In https://doc.qt.io/qt-6/sql-driver.html#qmysql-for-mysql-or-mariadb-5-6-and-higher
MYSQL_OPT_SSL_MODE is marked as SUPPORTED, this is a problem. -
Yee, That's the reason. As above, Source code of qsqlmysql plugin only supports a few connection options from https://dev.mysqlserver.cn/doc/c-api/8.4/en/mysql-options.html . MYSQL_OPT_SSL_MODE=SSL_MODE_DISABLED can disable SSL. But this option is NOT supported with "if" blocks in qsqlmysql codes.
MYSQL_OPT_SSL_MODE=SSL_MODE_DISABLED is important because that an OLD version mysql db contains large data may be still valuable.
In https://doc.qt.io/qt-6/sql-driver.html#qmysql-for-mysql-or-mariadb-5-6-and-higher
MYSQL_OPT_SSL_MODE is marked as SUPPORTED, this is a problem.@goldenhawking I'm not sure what you want to tell us but wrt MYSQL_OPT_SSL_MODE - the doc explicitly states: "Only available when linked against MySQL 5.7.10 or higher." which matches the actual source code ( https://github.com/qt/qtbase/blob/dev/src/plugins/sqldrivers/mysql/qsql_mysql.cpp#L1227 ).
-
@goldenhawking I'm not sure what you want to tell us but wrt MYSQL_OPT_SSL_MODE - the doc explicitly states: "Only available when linked against MySQL 5.7.10 or higher." which matches the actual source code ( https://github.com/qt/qtbase/blob/dev/src/plugins/sqldrivers/mysql/qsql_mysql.cpp#L1227 ).
@Christian-Ehrlicher Got it.
Quick sidebar: Let’s be real—MySQL just hasn’t had PostgreSQL’s cultural mindshare these past few years in the tech ecosystem.