Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secure binlog connection with SSL #70

Closed
kpuputti opened this issue Oct 27, 2015 · 7 comments
Closed

Secure binlog connection with SSL #70

kpuputti opened this issue Oct 27, 2015 · 7 comments

Comments

@kpuputti
Copy link

First of all, thanks for a great library! We are using the library in Clojure for replicating a MySQL instance to a separate database.

However, we have not been able to make a secure connection for streaming the binlog. We have managed to connect using SSL for normal jdbc SQL queries, so the setup and certificates are supposedly correct.

We get this error:

Unhandled com.github.shyiko.mysql.binlog.network.AuthenticationException
Access denied for user '...'@'...' (using password: YES)

When we try to set a custom socket factory to the BinLogClient that returns a new javax.net.ssl.SSLSocket using the javax.net.ssl.SSLSocketFactory.getDefault() factory, we get:

Caused by javax.net.ssl.SSLException
   Unrecognized SSL message, plaintext connection?

              InputRecord.java:  710  sun.security.ssl.InputRecord/handleUnknownRecord
              InputRecord.java:  527  sun.security.ssl.InputRecord/read
            SSLSocketImpl.java:  973  sun.security.ssl.SSLSocketImpl/readRecord
            SSLSocketImpl.java: 1375  sun.security.ssl.SSLSocketImpl/performInitialHandshake
            SSLSocketImpl.java:  928  sun.security.ssl.SSLSocketImpl/readDataRecord
           AppInputStream.java:  105  sun.security.ssl.AppInputStream/read
BufferedSocketInputStream.java:   51  com.github.shyiko.mysql.binlog.io.BufferedSocketInputStream/read
     ByteArrayInputStream.java:  202  com.github.shyiko.mysql.binlog.io.ByteArrayInputStream/readWithinBlockBoundaries
     ByteArrayInputStream.java:  175  com.github.shyiko.mysql.binlog.io.ByteArrayInputStream/peek
          BinaryLogClient.java:  332  com.github.shyiko.mysql.binlog.BinaryLogClient/connect
          BinaryLogClient.java:  520  com.github.shyiko.mysql.binlog.BinaryLogClient$4/run
                   Thread.java:  745  java.lang.Thread/run

Any pointers how to get a working SSL connection for binlog streaming? We are using the 0.2.4 version of the library.

Thanks!

@shyiko
Copy link
Owner

shyiko commented Oct 27, 2015

Hi. Unfortunately it's not implemented. At the very least we're missing SSL Request Packet (more details here) (followed by SSL exchange) + AuthenticateCommand & ClientCapabilities.SSL.
If you have some spare time and would like to give it at shot - I would be happy to merge such changes in. If not - sooner or later, I'll implemented it myself.

@kpuputti
Copy link
Author

Thanks for the response. We'll see what we can do.

@mvelliste
Copy link
Collaborator

I am finding this library super-useful too, thank you for creating it. But I am running into this very same SSL issue. I don't suppose there has been any progress on this?

@shyiko
Copy link
Owner

shyiko commented May 10, 2016

@mvelliste I'm afraid not. We're using IPsec so it never became an issue for us.

shyiko added a commit that referenced this issue Jun 29, 2016
@shyiko
Copy link
Owner

shyiko commented Jun 29, 2016

Tested on MySQL 5.6.31, running Java 8 (1.8.77).

CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%';
GRANT USAGE ON *.* TO 'username'@'%' REQUIRE SSL;
FLUSH PRIVILEGES;

(readme.md updated with usage instructions)

@thomas-woodruff
Copy link

@kpuputti

We have managed to connect using SSL for normal jdbc SQL queries

Hi there. How did you manage to connect to MySQL using SSL? I can't seem to find any documentation on this anywhere...

Thanks,
Tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants