1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-09-11 08:30:59 +03:00

1089 Commits

Author SHA1 Message Date
Georg Richter
136d295d02 Merge branch '3.1' into 3.3 2024-12-09 19:32:13 +01:00
Georg Richter
554893c269 CONC-711: Ubsan and ASAN fixes
- fixed write functions in my_auth.c
- fixed misalignment error when obtaining data via
  option MARIADB_OPT_USERDATA (mysql_get_optionv).
2024-12-09 19:28:10 +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
9541bd0e90 CONC-747: Change behaviour of MARIADB_TLS_DISABLE_PEER_VERIFICATION
Instead of skipping the verification during handshake,
tls_allow_invalid_server_certificate will be unset during
initialization of the connection handle if environment varible
MARIADB_TLS_DISABLE_PEER_VERIFICATION was set.

This will allow drivers and applications which don't have an API
option to enable/disable peer server certificate verification
to start without TLS/SSL.
2024-12-02 17:05:58 +01:00
Georg Richter
6a55b15520 Merge pull request #262 from markus456/3.4
CONC-741: Check that MYSQL_STMT is not null
2024-11-28 07:18:57 +01:00
Georg Richter
3590fe6e8b Merge branch '3.3' into 3.4 2024-11-27 16:17:12 +01:00
Georg Richter
b522ed1a43 Merge branch '3.1' into 3.3 2024-11-27 15:58:51 +01:00
Georg Richter
bdc66d6b8f Fix for CONC-703:
If connect failed and no error was set (apparently this happens
sometimes on Mac) we now set error to CR_SERVER_LOST.
2024-11-27 07:48:27 +01:00
Georg Richter
662a966056 CONC-702: Fix statement status
If a resultset in binary protpcpl doesn't contain data
(fields equal zero) and there are no more pending
result sets we need to change the statement status to
FETCH_DONE, otherwise it will be impossible to execute
other commands until the statement was closed.
2024-11-18 07:15:42 +01:00
Georg Richter
55e3b63c34 CONPY-739: prepared statement support AUTO_SEC_PART_DIGITS
FROM_UNIXTIME() function always returns AUTO_SEC_PART_DIGITS
(value=39). In case the microsecond value was set in MYSQL_TIME,
the decimal part should be SEC_PART_DIGITS (=6).
2024-11-15 17:41:23 +01:00
Vladislav Vaintroub
73823d9b56 Merge branch '3.3' into 3.4 2024-11-07 08:47:37 +01:00
Vladislav Vaintroub
76564675fc Merge 3.1 into 3.3 2024-11-07 08:47:12 +01:00
Vladislav Vaintroub
b1f1267805 CONC-527 post-fix.
Add fallback if CryptAcquireContext fails with ERROR_ACCESS_DENIED,
as seen in Jenkins CI.

The fallback, also suggested by https://stackoverflow.com/a/14053718/547065,
is to retry with machine-wide key container, if user-specific fails.
2024-11-07 08:30:59 +01:00
Markus Mäkelä
8dce8dba85 CONC-741: Check that MYSQL_STMT is not null
The code now again allows null MYSQL_STMT handles to be passed to
mysql_stmt_close(). Added a sanity check test case that should guard
against this happening in the future.
2024-11-07 07:34:12 +02:00
Markus Mäkelä
a2213b89d4 Add MYSQL_OPT_ZSTD_COMPRESSION_LEVEL
The compression level was always hard-coded to 3.
2024-11-07 06:51:57 +02:00
Georg Richter
000ed6281f Fix for CONC-740:
Moved the initialization of server verification callback from
mysql_init to mysql_real_connect to avoid memory leak in case
of a reconnect.
2024-11-05 12:51:51 +01:00
Vladislav Vaintroub
58d773da30 Schannel - parse TLSv1.0, but ignore attempt to use it
This is apparently what server test suite wants in tls_version.test
2024-10-30 08:39:57 +01:00
Sergei Golubchik
4aebdb600b fix certificate verification for GnuTLS
* don't verify trust unless requested
* don't error about host of untrusted certificates
* auto-verification replaces both TRUST and HOST
2024-10-28 15:06:31 +01:00
Georg Richter
53243b8a7a Follow up of d4a8ca9209
Last commit was incomplete
2024-10-23 13:08:42 +02:00
Georg Richter
d4a8ca9209 CONC-690: Remove OFF option for WITH_SSL
Due to required cryptographic functions which are part of the TLS
libraries it is no longer possible to build MariaDB Connector/C
without crypto libraries.
2024-10-23 08:04:21 +02:00
Georg Richter
a66f3fc302 Merge branch '3.3' into 3.4 2024-10-22 13:50:24 +02:00
Georg Richter
6635e4bdd6 Fix for CONC-735
If a reconnect occurs, we need to check if mysql->options.host was
already set and pass NULL instead of the previous host name.
2024-10-22 13:26:50 +02:00
Kristian Nielsen
3b29ff9c91 MDEV-34859: Failed to initialise non-blocking API on OpenBSD arm64
Follow-up patch to fix copy-paste error that causes incorrect restore of
registers in my_context_continue which can cause crashes on arm64.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-10-20 17:11:23 +02:00
Sergei Golubchik
6c0e755edf fix compilation errors with -flto
declare plugin structures using their correct type.
Fixes errors like

./libmariadb/libmariadb/ma_client_plugin.c:86:39: error: type of ‘pvio_socket_client_plugin’ does not match original declaration [-Werror=lto-type-mismatch]
./libmariadb/plugins/pvio/pvio_socket.c:141:21: note: type ‘struct MARIADB_PVIO_PLUGIN’ should match type ‘struct st_mysql_client_plugin’

Approved by: Georg Richter <georg@mariadb.com>
2024-10-17 10:02:07 +02:00
Sergei Golubchik
8ace383fa0 fix meaningless code in mariadb_time_to_string()
which was apparently supposed to print microseconds
2024-10-17 10:00:31 +02:00
Kristian Nielsen
da0a01367c Implement boost::context as a fallback for non-blocking API support
The non-blocking API has native (assembler) implementations for x86_64,
i386, and (with recent patch) aarch64; these implementations are the most
efficient. For other architectures, a fallback to ucontext is supported.

But ucontext is not the most efficient, and it is not available on all
platforms (it has been deprecated in POSIX). The boost::context library
provides an alternative fallback that is available on more architectures and
should be more efficient than ucontext (if still not quite as fast as the
native support).

This patch adds a CMake option -DWITH_BOOST_CONTEXT=ON that adds
boost::context as a dependency of libmariadb to provide a fallback on
non-natively supported architectures. Boost::context is preferred over
ucontext when both are available.

The option is off by default and must be explicitly enabled by the
user. This avoids introducing a C++ dependency (including dependency
on a C++ compiler and on libstdc++) unless explicitly requested by the
user (libmariadb is otherwise C-only).

Tested-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-09-27 15:33:43 +02:00
Kristian Nielsen
d2285fb830 MDEV-34859: Failed to initialise non-blocking API on OpenBSD arm64
Implement native my_context for arm64 (aarch64). This is more
efficient than ucontext, and also makes the non-blocking API available
on arm64 platforms that do not have ucontext such as OpenBSD.

Tested-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2024-09-27 15:32:43 +02:00
Georg Richter
7cb4b05d99 Fix for CONC-732: Always set verification callback (OpenSSL)
If peer certificate verification was disabled, we also need
to set the verification callback function to avoid output
from OpenSSL's internal fallback function.
2024-09-25 08:08:39 +02:00
Georg Richter
968b5f0aa2 Fix for CONC-731: wrong error message (incorrect fp)
- moved fingerprint verification to ma_tls.c
- don't verify cert again if fingerprint check
  succeeded.
- Disable self signed check in fingerprint tests
  (Schannel only).
2024-09-24 12:08:42 +02:00
Georg Richter
39f2e12f9a TLS verification: Added support for envvar MARIADB_TLS_DISABLE_PEER_VERIFICATION
If the environment variable MARIADB_TLS_DISABLE_PEER_VERIFICATION is
set, we will skip verification of the peer certificate.
2024-09-21 17:47:44 +02:00
Georg Richter
b465742c38 Merge branch '3.3' into 3.4 2024-09-21 15:34:26 +02:00
Georg Richter
ae3854159a Merge branch '3.1' into 3.3 2024-09-21 15:33:49 +02:00
Georg Richter
9a40079349 Fix possible crash, if no default plugin was loaded. 2024-09-20 16:52:46 +02: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
21b12feaad Revert "Fix usage of wait_io_or_timeout from TLS layers" 2024-09-15 07:18:44 +02:00
Georg Richter
b45eaa7c9a Merge pull request #250 from azat-ch/wait_io_or_timeout-fixes
Fix usage of wait_io_or_timeout from TLS layers
2024-09-12 19:40:45 +02:00
Georg Richter
e7b6adfbf9 Simplify tls_verification_callback 2024-09-10 07:19:12 +02:00
Georg Richter
b481c0a494 CONC-724: Added TLS verification callback support
For testing purposes (the python3 dummy server can't handle
further communication after TLS handshake succeeded) support
for verification callback was added.

my_bool callback(MYSQL *mysql, unsigned int *flags, my_bool verified)

Parameter:
  - mysql     connection handle for current connection
  - flags     verification flags
  - verified  true if callback was called after verification,
              otherwise false

Return value:
  - False (0) to continue
  - True  (1) to abort tls connection

The callback function can be registered via
mysql_optionsv(mysql, MARIADB_OPT_TLS_VERIFICATION_CALLBACK, callback);
2024-09-09 10:36:45 +02:00
Georg Richter
375720dc1c GnuTLS fixes:
To behave like OpenSSL and Schannel, we need to check the hostname,
even if other checks failed before.
2024-09-06 10:58:57 +02:00
Georg Richter
57f38cf87f Save the result of peer certificate verification
Since the MARIADB_TLS_VERIFY_TRUST flag might be cleared in my_auth,
we store the original result of peer certificate verification in
mysql->extension->tls_validation.
This value can be obtained via mariadb_get_infov API function
using option MARIADB_TLS_VERIFY_STATUS.
2024-08-31 07:53:46 +02:00
Georg Richter
4a157ffbb5 Merge branch '3.3' into 3.4 2024-08-31 07:37:31 +02:00
Georg Richter
c5ce23d340 Fix compiler warnings (schannel.c) 2024-08-30 07:39:46 +02:00
Georg Richter
dd8df0c8ec Fix for CONC-719 and CONC-720
- Fixed parsec plugin declaration (CONC-719)
- When using gnutls crypto, also link against libnettle and
  libhogweed to avoid build error due to unresolved externals.
2024-08-28 15:04:15 +02:00
Georg Richter
312b7eab4d Folow up of CONC-567 Schannel:
Added TLSv1.3 in ma_tls_get_protocol_version
2024-08-06 13:48:14 +02:00
Sergei Golubchik
0f3a41ec77 TLS post-fixes
* fix comments
* reorder errors to put hard errors on top
* report errors from openssl
* don't overwrite errors in C/C
* pass correct flags to gnutls_x509_crt_check_hostname2()
* use the same define name everywhere consistently
* don't recalculate fingerprint in openssl unnecessary
* misc
2024-08-03 16:37:57 +02:00
Vladislav Vaintroub
1e8e1f4f38 Fix "set but not used" warnings. 2024-07-31 20:48:44 +02:00
Vladislav Vaintroub
3ceb310ebe CONC-567 Schannel : support TLSv1.3
Use SCH_CREDENTIAL structure, to support TLSv1.3
Allow TLSv1.3 starting with Windows 11 / Server 2022, which are
first Windows releases to officially support latest TLS version
2024-07-31 20:48:34 +02:00
Vladislav Vaintroub
d15c73859c CONC-567 Schannel - handle SEC_I_RENEGOTIATE, prepare for TLSv1.3
There is no real renegotiation in TLSv1.3 protocol, so it is
some internal schannel thing, that makes DecryptMessage() to return
SEC_I_RENEGOTIATE, to replay a handshake step.

This pops up when TLSv1.3 is enabled.
2024-07-31 20:48:08 +02:00