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

SSL Connection error #425

Open
mani33 opened this issue Feb 17, 2023 · 3 comments
Open

SSL Connection error #425

mani33 opened this issue Feb 17, 2023 · 3 comments
Labels
awaiting-triage Issues awaiting proper priority/milestone assignment. bug

Comments

@mani33
Copy link

mani33 commented Feb 17, 2023

I installed MySQL server 8.0.32, matlab R2022b, Datajoint 3.5.0, mym 2.8.5 on my desktop 64 bit Windows 10 machine. When I typed in dj.conn( ) in matlab and entered credentials, I get the error:
“Error using mym
SSL connection error: unknown error number
Error in dj.Connection/query (line 167)
self.connId=mym(-1, ’open’, self.host, self.user, self.password, self.use_tsl); “

I tried using all the options including “No” for SSL tab in the Manage Connections tab of MySqlWorkbench. Error still persists.

@mani33 mani33 added awaiting-triage Issues awaiting proper priority/milestone assignment. bug labels Feb 17, 2023
@guzman-raphael
Copy link
Collaborator

@mani33 Thanks for moving this post to our issue tracker.

Before starting, I'll say that if using Python is an option, I'd highly recommend checking out datajoint-python as you will have an easier time. Contributions are much more active there and new features/fixes usually land there first.

Your issue is a bug but it is a bit involved to patch it properly. I'll outline some details and steps below so you can take the option that works best for you.

Problem

This problem is primarily related to the open mym issue datajoint/mym#55. Whenever we call dj.conn, it uses mym as the API to connect to MySQL. Until it is fixed, mym cannot make encrypted connections against MySQL >8.0.18.

dj.conn actually takes several arguments but all have defaults. Below is the full list of options.

dj.conn(host, user, pass, initQuery, reset, use_tls, nogui)
  • host : Database address.
  • user : Database user name.
  • pass : Database user password.
  • initQuery : Initializing function or query executed for each new session.
  • reset : Force a connection reset.
  • use_tls : Encrypt connection. Defaults to best available.
  • nogui : If true, will read prompt from terminal prompt.

TLS (or sometimes referred to as SSL) is the primary protocol by which communication is encrypted between client and server using certs. It is the best practice to encrypt when you can. By best available we mean that the connection is first attempted with encryption and if it fails, it is supposed to revert to unencrypted (though that is obviously not working for your setup).

Workaround

As workaround, you'll need to make a choice.

  1. Require encryption -> Suggest downgrading to MySQL 8.0.18 and trying again. Check out our MySQL Docker instructions to setup a DataJoint-optimized MySQL instance.
  2. Require latest MySQL but don't require encryption -> Set use_tls to false. Here is an example of what this looks like:
    dj.conn('fakeservices.datajoint.io', 'root', 'simple', '', true, false)
    Call this at the beginning of a DJ session or script.

Additional Notes

You might also run into the following issue:

Error using mym
Authentication plugin 'caching_sha2_password' cannot be loaded: /home/muser/MATLAB
Add-Ons/Toolboxes/mym/distribution/mexa64/caching_sha2_password.so: cannot open shared
object file: No such file or directory

Error in dj.Connection/query (line 167)
                self.connId=mym(-1, 'open', self.host, self.user, self.password,
                self.use_tls);

Error in dj.conn (line 107)
        query(connObj, 'status')

This is because MySQL changed their default authentication plugin from mysql_native_password to caching_sha2_password in 8.0.

The caching_sha2_password is still not supported in mym (datajoint/mym#52). The workaround is to change the authentication plugin on the server from caching_sha2_password to mysql_native_password. You can do this by setting the following config in your server's my.cnf.

[mysqld]
# Set default auth plugin
default_authentication_plugin=mysql_native_password

Hope this helps.

@mani33
Copy link
Author

mani33 commented Feb 18, 2023 via email

@noamza
Copy link

noamza commented Jul 11, 2024

This method didn't work for me but running the following on my localhost did:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newrootpassword'

and then connecting with TLS off as described above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-triage Issues awaiting proper priority/milestone assignment. bug
Projects
None yet
Development

No branches or pull requests

3 participants