[CONJ-670] MariaDB java connector ability to Refresh SSL certificate Created: 2019-01-04 Updated: 2019-02-08 Resolved: 2019-01-14 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | SSL |
| Affects Version/s: | None |
| Fix Version/s: | 1.8.0, 2.4.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Andrew Garner | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
We have some applications that run in a Cloudfoundry environment using the cloudfoundry java buildpack. In that environment, a security provider loads certificates from /etc/ssl/certs/ca-certificates.crt. When using mysql-connector-j, we find that CA certificates from this location are automatically trusted by our app and TLS connections are successfully established. However, when using the mariadb java connector, we always get an "unknown ca" error:
It seems that the MariaDB java connector is not finding the CA certificates loaded by the security provider and this does not affect mysql-connector-j. After some experimentation, we found that we could work around this problem by hardcoding the CA certificates location in our jdbcURL via the serverSslCert=/etc/ssl/certs/ca-certificates.crt (or similar). However, we would much prefer that the CA certificate is automatically trusted via the Cloudfoundry java buildpack's security provider rather than explicitly twiddling our jdbcURLs. |
| Comments |
| Comment by Diego Dupin [ 2019-01-07 ] | ||||||||||||||||||||||||||
|
Hi andrew, If you can provide some additional information to pinpoint the exact issue :
| ||||||||||||||||||||||||||
| Comment by Andrew Garner [ 2019-01-08 ] | ||||||||||||||||||||||||||
I've attached application logs. app_debug.log Curiously when I enable javax.net.debug=all I no longer see the "unknown_ca", but rather a Broken Pipe error. However, this seems to be caused by the SSL handshake failing, and it does go away once we explicitly set the serverSslCert.
Percona Server 5.7.23-23
jdbc:mysql://q-n3s3y1.q-g799.bosh:3306/service_instance_db?user=a2ef9950e97b418d8e85a13b8f8ff2a9\u0026useSSL=true\u0026requireSSL=true
We are not using mutual TLS or strictly requiring TLS on the mysql user level:
When our SSL connections work, we are using mysql-connector-java-5.1.45. We verify that we're making a SSL connection by checking performance_schema.threads:
Additionally we've verified that that MySQL connector was actually verifying our server certificate by reconfiguring the MySQL server with a certificated signed by an untrusted CA and seeing validation failures. | ||||||||||||||||||||||||||
| Comment by Steve Taylor [ 2019-01-09 ] | ||||||||||||||||||||||||||
|
We think the issue is here. Basically, the code returns the first x509 TrustManager it finds, ignoring any others that may be present. | ||||||||||||||||||||||||||
| Comment by Andrew Garner [ 2019-01-10 ] | ||||||||||||||||||||||||||
|
This change appears to work in our environment:
With this change, we seem to be hitting the path where we initialize the SSLContext:
I think with non-MariaDB connectors, there is a similar code path (SSLContext -> init()). This seems to explain why we only observe this behavior with the MariaDB Connector. | ||||||||||||||||||||||||||
| Comment by Diego Dupin [ 2019-01-11 ] | ||||||||||||||||||||||||||
|
This part :
is to just for "fast path" execution. It's probably due to the fact that SSLSocketFactory.getDefault() has been already used and storing default manager factory in static variables. I need to test that. | ||||||||||||||||||||||||||
| Comment by Diego Dupin [ 2019-01-14 ] | ||||||||||||||||||||||||||
|
confirmed. |