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

95 Commits

Author SHA1 Message Date
Georg Richter
4d46ae76bc Merge branch '3.1' into 3.3 2024-05-08 11:43:18 +02:00
Josh Hunt
4c1c7f37d6 Fix SSL_read/write return value checking in ma_tls_async_check_result
SSL_{read,write}'s return values == 0 signify the operation was
unsuccessful, but here it's being treated as success. Other calls of
these functions already properly checks the return value.

Signed-off-by: Josh Hunt <johunt@akamai.com>
2024-04-29 13:47:36 +02: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
Sergei Golubchik
a99570c118 MDEV-31855 SSL cert validation protocol extension
* extend the client auth plugin API with a new callback
* relax the plugin version check to allow load a plugin with the
  same major version, even if the minor versions differ
* implement the protocol extension:
  - don't abort at once if the certificate is self signed and
    no CA was explicitly specified
  - allow it if it passes fingerprint check
  - allow it if plugin has hash_password_bin callback, password was
    non-empty and the control hash matches server's
2024-02-04 22:17:25 +01:00
Georg Richter
9aa15e72a7 TLS fingerprint
Beside SHA1 fingerprint hash, Connector/C now also supports
SHA224 (OpenSSL and GnuTLS only), SHA256, SHA384 and SHA512
fingerprint hashes.
2024-02-04 22:17:22 +01:00
Georg Richter
3a255ee3ea Merge branch '3.1' into 3.3 2023-07-24 11:07:05 +02:00
Georg Richter
45feebb99d Remove server certification verification
Since the server certification option is used by client
only, there is no need to have this flag in server and or
client capabilities. The server itself validates client
certificate depending on the user definition.
2023-07-13 09:30:33 +02:00
Georg Richter
d9af4fcbc6 Merge branch '3.1' into 3.3 2022-11-07 09:09:29 +01:00
Sergei Golubchik
ad43ed2965 better error on aborted connection
according to `man SSL_get_error`

  The SSL_ERROR_SYSCALL with errno value of 0 indicates unexpected EOF
  from the peer. This will be properly reported as SSL_ERROR_SSL with
  reason code SSL_R_UNEXPECTED_EOF_WHILE_READING in the OpenSSL 3.0
  release because it is truly a TLS protocol error to terminate the
  connection without a SSL_shutdown().

let's use a conventional CR_SERVER_LOST in this case instead of
"TLS/SSL error: Success(0)"
2022-09-13 16:07:25 +02:00
Haidong Ji
020ed982b6 More robust call to X509_check_host using strlen not 0
Based on its interpretation of RFC 6125 section 6.4.2[^1], OpenSSL's
implementation[^2] of `X509_check_host` treats the `namelen` parameter
in a peculiar way:

- If `namelen` is non-zero, use it;
- Otherwise, use `strlen(name)` instead

There are now many forks of OpenSSL. Implementer of the forks may
interpret RFC 6125 section 6.4.2 a little differently. They may always
expect `strlen(name)` and NOT `0`. We have come across that with
AWS-LC[^3].  AWS-LC has agreed to make an adjustment so it is consistent
with OpenSSL in this matter. But other forks may not.

To make MariaDB connector C more robust, I think it's better that we
always pass `strlen(name)` instead of `0`. Unless there are compelling
reasons not doing so.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.

[^1]: https://www.rfc-editor.org/rfc/rfc6125.html#section-6.4.2
[^2]: https://www.openssl.org/docs/man3.0/man3/X509_check_host.html
[^3]: https://github.com/awslabs/aws-lc
2022-09-05 19:43:57 +00:00
Georg Richter
6dbd953420 Merge branch '3.1' into 3.3 2022-07-24 10:52:52 +02:00
Georg Richter
6700ee4a7c Make TLS/SSL more verbose:
Added TLS/SSL prefixes for error strings
Report Error string for errno
2022-07-21 09:47:23 +02:00
Georg Richter
e8e356e355 Merge branch '3.1' into 3.3 2022-07-18 11:48:33 +02:00
Georg Richter
9a572bc548 Fix for CONC-604 and CONC-605:
This patch fixes a crash when reconnectiong via TLS.
2022-07-18 11:41:46 +02:00
Georg Richter
5565de132d Merge branch '3.1' into 3.3 2022-07-08 07:49:24 +02:00
Georg Richter
f1b08b8369 Partial fix for MDEV-27405:
The return value of SSL_read indicates an error if it is <= 0, not
if it is < 0.
2022-07-08 07:46:00 +02:00
Georg Richter
3ba4c4a613 Merge branch '3.1' into 3.2 2022-04-20 18:55:05 +02:00
Georg Richter
3ce51b0b3e Fix for CONC-587:
Since alerts may happen after handshake (for example with described
test in CONC-587 using TLSv1.3 protocol or by renegotiation) the
tls error message needs to be retrieved if error is a protocol error
(SSL_ERROR_SSL) and/or if errno was not set.
2022-04-20 18:48:54 +02:00
Georg Richter
e730df7aaf Merge branch '3.1' into 3.2 2021-11-03 16:35:27 +01:00
Georg Richter
b2bb1b213c Fix for CONC-570:
Removed callback function for crypto threads, since the callback function
cannot be cleared. For OpenSSL <= 1.0.2 the default implementation will be used:
address of errno (Posix) or GetCurrentThreadId (Windows).
2021-11-03 16:29:45 +01:00
Georg Richter
971489fa44 Reverted remove of TLSv1.0 protocol
TLSv1.0 protocol was removed by mistake
in commit e4e5b28452
2021-06-08 10:13:02 +02:00
Georg Richter
e4e5b28452 CONC-533: Support for asynchronous statements (binary protocol)
Added a new option MARIADB_OPT_SKIP_READ_RESPONSE which skips automatic
reading of server response after sending a command to the server.

Server packets have to be retrieved by calling the corresponding methods,
e.g:

Send command                         Read method
mysql_real_query/mysql_send_query    db_read_query_result
mysql_stmt_prepare                   db_read_prepare_response
mysql_stmt_execute,
mariadb_stmt_execute_direct          db_read_execute_response
2021-05-13 21:21:43 +02:00
Georg Richter
6cf8ccc14f Build fix for OpenSSL 1.1.0 2020-10-06 15:30:05 +02:00
Georg Richter
ee2216aa3f Build fix for OpenSSL < 1.1 2020-09-18 09:25:08 +02:00
Georg Richter
65cf891e49 CONC-501: Support for TLSv1.3 cipher suites
Added support for TLSv1.3 cipher suites, which require a separate API call.
2020-09-18 08:31:03 +02:00
Georg Richter
159540fe8c OpenSSL fixes:
Since we still need to support OpenSSL 1.0.2 everything is now loaded
in context instead of ssl.
If handshake failed, we now call SSL_get_verify_result for getting a more
defailed error message in case certificate alerts were raised (e.g. revocation)
2020-09-17 10:41:01 +02:00
Georg Richter
f885593e59 Don't load certificates in global context. 2020-09-16 07:42:06 +02:00
Georg Richter
0157f3db88 Revert "Follow up of 7b8b5ddae280b2d33e2b3fce8446f679521a75be:"
The fix fails with ssl_crl server test, since certificates are loaded
in global context. If there is a valid certificate in global context,
certificate revocation test on server will fail.

This reverts commit db385afbbe.
2020-09-16 07:28:41 +02:00
Georg Richter
db385afbbe Follow up of 7b8b5ddae2:
Since we load the certificate chain in context, we need to load also key in context.
2020-09-15 17:14:15 +02:00
Georg Richter
7b8b5ddae2 Fix for CONC-500:
Only use SSL_CTX_use_certificate_chain_file to load and check the certificate.
2020-09-14 17:21:19 +02:00
Georg Richter
8e9c311610 Follow up of ffbdaaac2b
commit ffbdaaac2b was incomplete, changes from ma_pvio.c
were missing. Beside this fix, this commit also contains necessary changes for GnuTLS.
2020-01-22 11:08:18 +01:00
Georg Richter
ffbdaaac2b TLS/OpenSSL fix:
If ssl_verify_server_cert or MYSQL_OPT_SSL_VERIFY_SERVER_CERT option was set
without setting a local ca file, the server certificate will be checked using
the system ca store.
This might lead to an error, in case the server certificate was self signed.
In this case, the preferred way is to specify a local CA.
2020-01-20 17:30:17 +01:00
Georg Richter
77d051e89d Windows build fixes for OpenSSL 2019-07-16 08:52:24 +02:00
Vladislav Vaintroub
b508716117 MDEV-18131 MariaDB does not verify IP addresses from subject alternative names 2019-04-24 12:46:00 +01:00
Georg Richter
54afa039df Fix build with deprecated OpenSSL API:
Err_remove_state is deprecated since OpenSSL 1.0.0 - we use now ERR_remove_thread_state instead.
Kudos to Rosen Penev for providing this patch.
2019-02-03 21:14:49 +01:00
Georg Richter
418e3381a7 Fix for CONC-375: SSL handshake fails
Since new TLSv1.3 cipher suites differ from older cipher suites they can't me mixed and need
to be set by a different API call, we disable the settings for TLSv1.3 cipher suites.
2018-11-27 08:14:33 +01:00
Vladislav Vaintroub
17d0e53176 Fix broken build with Windows OpenSSL. 2018-09-08 15:47:17 +01:00
Sergei Golubchik
0e0bf9aa49 Merge tag 'v3.0.6' into 10.3-server 2018-08-10 15:01:16 +02:00
Sergei Golubchik
3db62d628d Merge branch '10.2-server' into 10.3-serg 2018-08-10 14:24:53 +02:00
Sergei Golubchik
d0f201451d SLES11 OpenSSL 0.9.8 support 2018-08-09 11:27:36 +02:00
Georg Richter
f1fd014a15 Fixed leak in ma_tls_read/write 2018-07-31 09:39:03 +02:00
Georg Richter
df07debedd Support for -Wlogical-op flag and warning fixes (Patch provided by Monty) 2018-05-12 10:48:26 +02:00
Georg Richter
7775af75b4 Fix for CONC-326:
ssl_thread_init() uses wrong openssl threadid callback
2018-05-12 10:48:26 +02:00
Georg Richter
f8ea603fca CONC-321:
Added support for OpenSSL 1.1.1
Tested with OpenSSL 1.1.1 beta 5. For testing TLS v13 the server needs to be patched with patch attached to MDEV-15996.
2018-04-24 18:26:07 +02:00
Georg Richter
1c194bd78f Support for -Wlogical-op flag and warning fixes (Patch provided by Monty) 2018-04-24 17:18:31 +02:00
Georg Richter
966ad42cee Fix for CONC-326:
ssl_thread_init() uses wrong openssl threadid callback
2018-04-24 12:21:07 +02:00
Georg Richter
f226c3b257 Fix for CONC-320:
Non blocking/asynchronous support for OpenSSL and GnuTLS.
Please note that Schannel in asynchronous mode is not supported yet.
2018-04-17 10:35:49 +02:00
Georg Richter
929614903e Travis and Appveyor integration:
- added travis support
  - fixed appveyor settings
  - fixed some warnings (gcc 4.8)
  - removed sleep commands
  - disabled failing tests when running against MySQL server,
    mostly related to stored procedures and binary protocol
  - reverted fix for MDEV_10361

Still open: TLS/SSL appveyor tests, since .msi installation on appveyor doesn't provide certificates.
2018-02-16 12:14:01 +01:00
Georg Richter
b241f8995f MDEV-14101: tls-version
Client part of MDEV-14101: Add support for tls-version, via
mysql_options(mysql, MARIADB_OPT_TLS_VERSION, value)
Accepted values are "TLSv1.1", "TLSv1.2" and "TLSv1.3".

Fixed testcase openssl_1 for schannel
2017-10-23 11:09:54 +02:00