1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

182 Commits

Author SHA1 Message Date
Georg Richter
b38e872003 Text fixes:
Fixed windows test (missing parameter)
Check if we need to connect via SSL port (Travis)
2025-03-05 13:39:22 +01:00
Georg Richter
605f30f754 Merge branch '3.3' into 3.4 2025-02-27 11:09:55 +01:00
Georg Richter
0ff64ca045 Merge branch '3.1' into 3.3 2025-02-27 09:35:33 +01:00
Georg Richter
f7633e9d68 Test fix: pipe name
Instead of relying on default (MySQL), we check @@socket and
pass the correct pipe name.
2025-02-27 09:33:35 +01:00
Georg Richter
13c693f28b Merge branch '3.3' into 3.4 2025-02-27 07:56:47 +01:00
Georg Richter
4c9bc2b0f6 Merge branch '3.1' into 3.3 2025-02-27 07:52:35 +01:00
Georg Richter
aa240cd181 CONC-760: valid named pipe connection is closed
Fixed different behavior of pvio_is_alive (which was first used
with fix of CONC-589). Both for sockets and named pipe the function
now returns true if the connection is alive, otherwise false.
2025-02-27 07:48:58 +01:00
Georg Richter
eda920ec0f Merge branch '3.3' into 3.4 2025-02-18 16:35:55 +01:00
Georg Richter
1e4e47347d test fix: use my_ulonglong instead of ulong
Use 64-bit long instead of 32-bit value to avoid
overflow
2025-02-11 19:38:55 +01:00
Sergei Golubchik
93e420621a CONC-746 parsec plugin not unloaded during mtr test run
* check for client's parsec.so before installing server's auth_parsec.so
* find the plugin using the default connection (that has MYSQL_PLUGIN_DIR set)
* copy is_mariadb check from ed25519 tests, just in case
2025-01-25 19:57:46 +01:00
Sergei Golubchik
a99205eb36 Merge branch '3.3' into 3.4 2025-01-25 18:06:27 +01:00
Sergei Golubchik
2d56f340c4 Merge branch '3.1' into 3.3 2025-01-24 14:52:35 +01:00
Sergei Golubchik
7d930974c0 CONC-751 unit.conc_connection fails with CYPHER missmatch on some builds
disable the test for old gnutls
2025-01-24 14:42:37 +01:00
Georg Richter
5f4b9b6e8c Travis fix: Skip reconnect test (MaxScale) 2025-01-21 14:21:33 +01:00
Georg Richter
ba64123b45 Merge branch '3.3' into 3.4 2025-01-20 09:58:34 +01:00
Georg Richter
362be9e919 Travis fixes:
- run reconnect test without server certificate verification
- moved conc336 to manual tests (should run with valgrind).
2025-01-15 13:16:32 +01:00
Georg Richter
53b7169315 Merge branch '3.1' into 3.3 2025-01-15 10:46:29 +01:00
Georg Richter
36d1c3ac77 Travis fix: Skip reconnect test (MaxScale) 2025-01-15 10:41:32 +01:00
Georg Richter
57ce0ce3c7 Merge branch '3.1' into 3.3 2025-01-15 08:00:19 +01:00
Georg Richter
e09e24e890 CONC-589: First query fails after reconnect
If automatic reconnect is enabled (MYSQL_OPT_RECONNECT) it is
mandatory to check if the connection/socket is still alive before
sending a command to the server (unless the command is COM_QUIT).
2025-01-15 07:26:18 +01:00
Georg Richter
fa9f5f66be Travis and test fixes:
- Build server build with latest C/C: Instead of copying the C/C directory
  into server, we now fetch the actual commit or PR into server repository
- Fix travis environment variables (Windows)
- Skip character set tests if the server doesn't support charset/collation
- Don't use CREATE OR REPLACE SQL syntax to make MySQL happy
- Disable TLS connection test for MaxScale
- Don't set TEST environment variables if they are empty
2025-01-07 16:57:53 +01:00
Georg Richter
52d0a38ed1 Merge branch '3.3' into 3.4 2024-12-21 08:42:03 +01:00
Georg Richter
486a07c824 Test fix:
use mysql_real_connect instead of my_test_connect for unix_socket
test to reduce diagnostic output from my_test_connect function.
2024-12-21 08:33:15 +01:00
Georg Richter
4039e5c18c Merge branch '3.3' into 3.4 2024-12-21 08:10:04 +01:00
Georg Richter
5485acd470 Test case fix:
Don't connect with anonymous user, since mtr doesn't run with
unix_sockets by default.
2024-12-20 12:02:35 +01:00
Georg Richter
0d2d49eb26 Fix for connection test:
Test failed under mtr, since mtr doesn't run by default using
unix socket.
2024-12-20 11:59:53 +01:00
Georg Richter
32addee3fc Test case fix:
Don't connect with anonymous user, since mtr doesn't run with
unix_sockets by default.
2024-12-20 06:14:02 +01:00
Georg Richter
d64461c742 Test fixes:
- fixed tls callback function declarations
- fixed memory leaks
2024-12-09 18:49:52 +01:00
Georg Richter
1329a50e79 Added test for CONC-589 2024-12-09 14:01:34 +01:00
Georg Richter
fb0eea663a Merge branch '3.3' into 3.4 2024-12-08 12:01:20 +01:00
Georg Richter
6d28fe89af Merge branch '3.1' into 3.3 2024-12-08 11:50:43 +01:00
Georg Richter
af44fc5c5e CONC-748: Allow to set TLSv1.3 ciphers in GnuTLS
- Added TLSv1.3 ciphers to cipher map.
- Fixed retrieval of cipher suite: Since gnutls_cipher_suite_get_name
  supports only TLSv1.2 (and lower) cipher suites, we have to call
  gnutls_ciphersuite_get() (requires GnuTLS 3.7.4 or newer).
2024-12-08 11:27:32 +01:00
Georg Richter
47ba1f3d5b CONC-746: unload parsec plugin in test
After running test_parsec test (unittest connection)
we need to unload the parsec plugin in server to make
mtr happy.
2024-11-27 16:37:08 +01:00
Georg Richter
a6fd09f1df OpenSSL timeout fix:
Since timeout was already set via setsockopt, we call wait_io_or_timeout()
with a very small timeout (5ms) to get a more precise errno, which is used
by OpenSSL's error function.
2024-09-17 10:58:25 +02:00
Georg Richter
fb0496cd81 Fixed plugin header and added parsec test 2024-08-28 18:22:53 +02:00
Georg Richter
db43d63817 removed x509 test from connection
x509 tests are in tls test already
2024-07-18 09:58:05 +02:00
Georg Richter
1287c901dc TLS/SSL changes (major rework)
Peer certificate validation:

Since version 3.4 peer certificate verification is enabled by default.
It can be disabled via `mysql_optionsv`, using option
MYSQL_OPT_SSL_VERIFY_SERVER_CERT:

    my_bool verify= 0;
    mysql_options(mariadb, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify);

Self signed certificates

If the client obtained a self signed peer certificate from MariaDB server
the verification will fail, with the following exceptions:

* If the connection between client and server is considered to be secure:, e.g.
  * a unix_socket is used for client server communication
  * hostname is localhost (Windows operating system), 127.0.0.1 or ::1
* a specified fingerprint matches the fingerprint of the peer certificate (see below)
* a client can verify the certificate using account password, it's possible if
  * account has a password
  * authentication plugin is "secure without TLS", that is, one of
    mysql_native_password, ed25519 or parsec.

Fingerprint verification of the peer certificate

A fingerprint is a cryptographic hash (SHA-256, SHA-384 or SHA-512) of the peer
certificate's binary data. Even if the fingerprint matches, an expired or
revoked certificate will not be accepted.

For security reasons support for MD5 and SHA1 has been removed.

Technical details:
==================

- Peer certificate verification call was removed from ma_tls_connect, instead it
  will be called directly after the handshake succeeded (my_auth.c)

- mysql->net.tls_self_signed_error was replaced by mysql->net.tls_verify_status which
  contains the result of the peer certfificate verification:

  The verification status can be obtained with mariadb_get_infov using new parameter
  MARIADB_TLS_VERIFY_STATUS.

  unsigned int tls_verify_status;
  mariadb_get_infov(mysql, MARIADB_TLS_VERIFY_STATUS, &tls_verify_status);

  The result is a combination of the following flags:

  MARIADB_TLS_VERIFY_OK                  0
  MARIADB_TLS_VERIFY_TRUST               1
  MARIADB_TLS_VERIFY_HOST                2
  MARIADB_TLS_VERIFY_PERIOD              4
  MARIADB_TLS_VERIFY_FINGERPRINT         8
  MARIADB_TLS_VERIFY_REVOKED            16
  MARIADB_TLS_VERIFY_UNKNOWN            32

- GnuTLS peer certificate verification callback was removed and replaced by
  gnutls_verify_peers2() api function, so the peer certificate validation
  will happen after handshake.

- OpenSSL implementation will no longer use SSL_verify_result to check the
  validity of the peer certificate. Instead a callback function will be called
  during the handshake, which collects all certificate validation errors.

- If the peer certificate is not trusted, hostname verification will be
  skipped.

- Testing
  Added new test tls, which implements a python based dummy server, which allows
  to set different certificates and TLS options. Please note. that tests are
  expected to fail, since the server doesn't support further steps like user
  authentication etc. after the handshake. Prerequisite for running the tls test
  is Python3.
2024-07-16 13:12:26 +02:00
Georg Richter
7498d30a07 CONC-698: certificate info is read on every connect
Read and store peer certificate information only if
mariadb_get_options was called.
2024-06-21 16:14:36 +02:00
Georg Richter
f97bb2e92e Fix failing tests when server runs on a different machine 2024-06-10 13:19:49 +02:00
Georg Richter
55fe56fa42 Fix for CONC-505:
Don't allow to specify unsupported client flags (like
CLIENT_DEPRECATE_EOF) as client flag in mysql_real_connect
api function.
2024-05-08 14:22:13 +02:00
Georg Richter
3652e503b7 Disable test for MAXSCALE 2024-04-30 13:22:38 +02:00
Georg Richter
19dffea4dc CONC-692: Provide X509 peer certificate information
Added a new structure MARIADB_X509_INFO, which
contains information about servers certificate.
The information can be obtained via mysql_get_infov API
function:

MARIADB_X509_INFO *info;
mariadb_get_infov(mysql, MARIADB_TLS_PEER_CERT_INFO, &info);
2024-04-24 11:21:28 +02:00
Georg Richter
ebe1949540 Fix for CONC-505:
Don't allow to specify unsupported client flags (like
CLIENT_DEPRECATE_EOF) as client flag in mysql_real_connect
api function.
2024-02-22 09:03:51 +01:00
Sergei Golubchik
f6e99af056 Revert "self-signed certificate verification", it's 3.4 feature
This reverts 395641549ac7..536d9e2b9e5b, in particular:

8dffd56936 MDEV-31857 enable MYSQL_OPT_SSL_VERIFY_SERVER_CERT by default
a99570c118 MDEV-31855 SSL cert validation protocol extension
9aa15e72a7 TLS fingerprint

and related commits
2024-02-19 11:16:26 +01:00
Sergei Golubchik
8dffd56936 MDEV-31857 enable MYSQL_OPT_SSL_VERIFY_SERVER_CERT by default
because the default value of every option is 0
(option and option.extension are bzero-ed to reset),
tls_verify_server_cert was renamed to tls_allow_invalid_server_cert
with the default value of 0, "do not allow".

API didn't change, it's still MYSQL_OPT_SSL_VERIFY_SERVER_CERT
2024-02-04 22:17:25 +01:00
Georg Richter
00fb2062b9 Test fix for MaxScale:
Skip character set tests which set character set
during handshake, since MaxScale sends utf8mb4 via
session_track information in handshake OK packet.
(https://jira.mariadb.org/browse/MXS-4898).
2023-12-14 09:07:44 +01:00
Georg Richter
b0a2f65f55 Character set test:
Added diagnostic output.
2023-12-14 08:01:46 +01:00
Georg Richter
ba55b5b78f Test fix:
Append terminating 0 in status_callback_function.
2023-12-13 18:46:55 +01:00
rusher
dd927bd171 Update server test suite 2023-08-30 09:52:22 +02:00
Georg Richter
cd59c70ce7 Merge branch '3.1' into 3.3 2023-08-10 11:20:29 +02:00