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

667 Commits

Author SHA1 Message Date
Georg Richter
80ec04f116 CONC-413: Add test for checking IP in peer cert SAN 2024-12-09 13:13:22 +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
232e81f021 Add test case for CONC-176 2024-12-04 10:13:21 +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
fa987a3bc4 Added test case for CONC-163 2024-12-02 06:36:56 +01:00
Georg Richter
cc68f677ca Fix test case for CONC-741 2024-11-30 07:28:34 +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
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
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
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
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
Georg Richter
f595e6d1a6 Remove doxygen check
This was errnously copied from wrong testing branch.
2024-10-10 15:22:57 +02:00
Georg Richter
d00de5f997 Travis fixes:
- Build x64 (for some unknown reason default windows build
  on travis is x86)
- Disable conc336
2024-10-02 10:23:40 +02:00
Georg Richter
d358547dd0 TLS test fix:
We always need to set verification flag in tls test, to avoid
failing tests if Connector/C was built with option
DEFAULT_SSL_VERIFY_SERVER_CERT=OFF
2024-09-25 08:28:56 +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
3973fb84bb Merge branch '3.3' into 3.4 2024-09-20 08:38:52 +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
858a3e36b7 Fix typo (thanks to OttoK). 2024-09-12 18:44:51 +02:00
Georg Richter
e7b6adfbf9 Simplify tls_verification_callback 2024-09-10 07:19:12 +02:00
Georg Richter
dfdf3f7557 CONC-712: Don't verify hostname on local connection
Hostname verification is skipped if the connection
is a local connection and is considered secure
(127.0.0.1, localhost, ::1).
2024-09-09 11:12:56 +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
80be17e99d Test fix: Fix paths for tls_server 2024-09-03 06:06:19 +02:00
Georg Richter
2cc31e8768 Disable TLSv1.0 test
New schannel implementation requires TLSv1.2 or TLSv1.3
2024-08-31 08:27:48 +02:00
Georg Richter
fb0496cd81 Fixed plugin header and added parsec test 2024-08-28 18:22:53 +02:00
Sergei Golubchik
de6305915f Merge remote-tracking branch 'origin/3.4' into HEAD 2024-08-03 16:38:02 +02:00
Marko Mäkelä
4681372f9c CONC-700: Fix gcc-14 -Wcalloc-transposed-args 2024-07-31 10:05:00 +03: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
e308fae99b tls test fix:
Skip tests with passwords using self signed certificate
when running against servers < 11.4
2024-07-18 09:40:56 +02:00
Georg Richter
109ec58608 tls test fixes:
Always specify port and socketname (otherwise
we can't test against external servers)
2024-07-18 08:38:17 +02:00
Georg Richter
efbc562477 tls test fix:
- Don't skip ca test when running with schannel.
- Load new self signed cert after expiration test
2024-07-17 11:56:44 +02:00
Georg Richter
ea307b8d6e Travis fixes for windows 2024-07-17 11:06:52 +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
Sergei Golubchik
def5dee9d5 Merge remote-tracking branch 'origin/3.3' into 3.4-serg 2024-05-13 16:00:45 +02:00
Georg Richter
072dadc392 Disable test when running against MySQL server 2024-05-13 15:54:04 +02:00
Sergei Golubchik
11168e8798 Merge remote-tracking branch 'origin/3.4' into 3.4-serg 2024-05-13 15:53:23 +02:00
Georg Richter
cba62ec2be Fix character set test.
Added a list of unsupported collations which
were added in 11.5
2024-05-10 10:26:44 +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
bf0d299ae4 Text fix: Avoid crash in non TLS connections 2024-04-30 12:04:15 +02:00
Georg Richter
c6fa37300a Fix SKIP_TLS macro (unittest)
Since in 3.4 we use TLS connections by default, so checking force_tls
is not enough. We also need to check if fingerprint was set.
2024-04-30 11:33:04 +02:00
Georg Richter
a63b826195 test fix: Always specify fingerprint for TLS connections 2024-04-30 11:06:09 +02:00
Georg Richter
a25049ba49 Remove temp. diagnostic information 2024-04-29 11:17:35 +02:00
Georg Richter
9644f52796 Skip async test on Windows
Schannel implementation doesn't support async mode yet.
2024-04-29 11:15:32 +02:00
Georg Richter
45179cffc4 Merge remote-tracking branch 'origin/3.1' into 3.4 2024-04-29 11:15:02 +02:00