Added an option STMT_ATTR_SQL_STATEMENT in API function
mariadb_stmt_attr_get which returns a MARIADB_CONST_STRING
structure which contains SQL statement from last
mysql_stmt_prepare() call.
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.
/home/buildbot/buildbot/build/libmariadb/unittest/libmariadb/ps.c:5152:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (unsigned int i=0; i < mysql_field_count(mysql); i++)
^
/home/buildbot/buildbot/build/libmariadb/unittest/libmariadb/ps.c:5152:3: note: use option -std=c99 or -std=gnu99 to compile your code
Fixed max_length values in ma_stmt_codecs for integer types:
- all types included an extra byte for trailing zero character
- maximum value for year column type is 2155 (and not 0xFFFF).
Various coverity scan fixes, including CONC-452 and CONC-453.
Special thanks to Lukas Javorsky for fixing numerous covscan
issues (This patch includes part of his pull request #126).
Coverity scan build was using the following cmake parameters:
-WITH_EXTERNAL_ZLIB=ON -DWITH_UNIT_TESTS=OFF.
CWE-416 (use after free) in dtoa.c (from netlib) is still open.
POWER and other architectures that define char(as my_bool) to be unsigned (as the C
standard leaves this undefined). This resulted in error branches being
unreachabe as indicated by the below compile warnings.
plugins/pvio/pvio_socket.c:763:42: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
false [-Wtautological-constant-out-of-range-compare]
if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
plugins/pvio/pvio_socket.c:875:46: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
false [-Wtautological-constant-out-of-range-compare]
if (pvio_socket_blocking(pvio, 0, 0) == SOCKET_ERROR)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
plugins/pvio/pvio_socket.c:907:42: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
false [-Wtautological-constant-out-of-range-compare]
if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)
ma_hext2int: signed char - prevent compiler errors when char is unsigned.
libmariadb/ma_tls.c:169:31: warning: comparison of constant -1 with expression of type 'char' is always false
[-Wtautological-constant-out-of-range-compare]
if ((d1 = ma_hex2int(*p)) == - 1 ||
~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
libmariadb/ma_tls.c:170:35: warning: comparison of constant -1 with expression of type 'char' is always false
[-Wtautological-constant-out-of-range-compare]
(d2 = ma_hex2int(*(p+1))) == -1 ||
~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~
To fix this all the pvio_*_blocking functions have been changed to use
int as a return value.
Other my_bool/char differences fixed:
mariadb_dyncol_val_str: fix prototype to use char - like implemented function.
unittest: bind.is_null is my_bool* so we use a my_bool.
for api functions which require string with length parameter (e.g.
mysql_real_connect() or mysql_stmt_prepare() we now use the macro
SL(string) which substitutes string and string length.
- 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.
If a statement with open (read only) cursor is executed there is no buffered
result set (result set rows will be fetched directly from server), so we need to skip reading unbuffered result sets if a cursor is open.
- SSL tests require CERT_PATH. Subdirectory certs was removed. If Connector/C is build outside of the server tree, certification path has to be specified manually (-DCERT_PATH=/path/to/certs).
- All tables and users will removed, if the test passed (otherwise mtr will complain).
- allow param binding via mysql_stmt_attr_set:
mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, ¶m_count);
- If a prepared statement will be reexecuted, we send COM_STMT_CLOSE
together with COM_STMT_PREPARE and COM_STMT_EXECUTE
- TLS/SSL: renamed HAVE_SSL to HAVE_TLS to avoid trouble in
10.2-integration
- Fixed wrong timeout in non-blocking mode
- Fixed valgrind error in prepared statement