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

12 Commits

Author SHA1 Message Date
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
4ab155cf39 Unit test fixes for server integration
- 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).
2017-03-04 17:37:39 +01:00
Georg Richter
c20974b039 - removed global context for tls, so code can be used also with no yassl branch in 10.2
- added new gnutls cipher mapping
- fixed ssl test case: skip hostname verification if both server and client run on localhost
- added server certificates
2016-10-17 16:02:51 +02:00
Georg Richter
a3bb1d2009 merge from 3.0.0 fixes 2015-12-29 21:06:23 +01:00
Georg Richter
f8ebc60f8f Fix for Conc-127: MariaDB Connector/C accepts dummy/self signed CA's 2015-03-15 19:10:33 +01:00
Georg Richter
088fdacfc1 Fixed vio for non-blocking API calls 2014-11-12 18:10:22 +01:00
Georg Richter
d12429bf99 Fix for CONC-102:
Since we use one SSL context per library instance (which might be shared by several threads) we need to protect
certification loading by a mutex.
2014-10-12 05:35:43 +02:00
holzboote@googlemail.com
b9676202a9 Fix for CONC-95: SSL connection with require X509 privilege doesn't work.
- all pems and ciphers are now stored in global context
- create new ssl instance after loading pems into global context
2014-06-23 09:23:14 +02:00
Georg Richter
08bb38885f Fix for CONC-81: crash in ssl connection (caused by fix for CONC-79)
- prevent zeroing cache paraemters in vio_reset
2014-03-03 17:10:00 +01:00
holzboote@googlemail.com
3af3d85660 Fixed bug in prepared statements: wrong length for MYSQL_TYPE{TIME,DATETIME,TIMESTAMP}
renewed test certificates for ssl tests
2013-10-27 19:38:11 +01:00
holzboote@googlemail.com
b382649f50 More SSL fixes:
- verification functions for key and cert now use SSL_context
        - Added support for server cert verification (hostname must match)
        - minor bug fixes
2013-09-19 15:14:11 +02:00
Georg Richter
11f01e9fed Fixes for SSL
- fix for php bug 51647
  - added cert store
  - added certificates for testing
2012-12-01 14:02:34 +01:00