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

Initial handshake problem #351

Closed
jasdefer opened this issue Oct 9, 2017 · 8 comments
Closed

Initial handshake problem #351

jasdefer opened this issue Oct 9, 2017 · 8 comments
Assignees
Labels

Comments

@jasdefer
Copy link

jasdefer commented Oct 9, 2017

When connecting to my 10.0.31-MariaDB database, I get an exception during the initial handshake.
The problem occurs while reading the AuthPluginName. The FormatException Read past end of buffer looking for NUL. is thrown in the MySql.Data.ByteArrayReader.ReadNullTerminatedByteString() method. Even though the AuthPluginName should be mysql_native_password (see the provided byte buffer below).

m_offset=71, m_maxOffset=92 and the buffer (m_buffer) is

    [...]
    [70]: 0
    [71]: 109
    [72]: 121
    [73]: 115
    [74]: 113
    [75]: 108
    [76]: 95
    [77]: 110
    [78]: 97
    [79]: 116
    [80]: 105
    [81]: 118
    [82]: 101
    [83]: 95
    [84]: 112
    [85]: 97
    [86]: 115
    [87]: 115
    [88]: 119
    [89]: 111
    [90]: 114
    [91]: 100
    [92]: 0
    [93]: 0
    [94]: 0

I understand that index == m_maxOffset is true and therefore the exception is thrown.
When removing the following two lines from the ReadNullTerminatedByteString method, the connection can be established without any problems:

if (index == m_maxOffset)
    throw new FormatException("Read past end of buffer looking for NUL.");

I obviously don't want to remove those lines for production. Can someone help me out?

@bgrainger
Copy link
Member

I'm not seeing this exception when running the tests against the mariadb:10.0.32 Docker image. Would it be possible for you to perform a packet capture (with Wireshark, tcpdump or similar) and attach it here (or email it to me privately)?

@jasdefer
Copy link
Author

I just use Wireshark to capture the packets. I noticed the following package using the MySQL protocol with the info Server Greeting proto=10 version=5.5.5-10.0.31-MariaDB[Malformed Packet].
I assume the problem is the malformed packet, but I can send you all the packages if it helps.

@bgrainger
Copy link
Member

Yes, the malformed packet does sound like the problem (and it would appear that Wireshark's protocol analyser also identifies there is a problem).

Do you have a direct connection to your MariaDB server, or is there some some of proxy / load balancer / etc. in between?

@jasdefer
Copy link
Author

jasdefer commented Oct 11, 2017

Even with the malformed packet I still get the message (when following the TCP stream in Wireshark):

X...
5.5.5-10.0.31-MariaDB.#"	.]|{rIX[B...!..?............wSuvoJa-YZ8E.mysql_native_password

The database is really behind something, I think a proxy. I just asked the system administrator for details. I will post his answer when he replies.

Thank you for your help so far :)

@jasdefer
Copy link
Author

I just got a response:
The database is only accessible when connected to the same network as the database (which I am). There is a MySQL proxy in front of the database. The whole thing is behind a service chain with a load balancer. The load balancer sends the requests of a session always to the same MySQL proxy.

@bgrainger
Copy link
Member

I just found this in the archived docs:

  • auth_plugin_name (string.NUL) -- name of the auth_method that the auth_plugin_data belongs to

Note
Due to Bug#59453 the auth-plugin-name is missing the terminating NUL-char in versions prior to 5.5.10 and 5.6.2.

I'll update the connector to not require a null-terminator.

@bgrainger
Copy link
Member

Fixed in 0.28.2.

@bgrainger bgrainger added the bug label Oct 11, 2017
@bgrainger bgrainger self-assigned this Oct 11, 2017
@jasdefer
Copy link
Author

Awesome it works! Thank you very much.

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

No branches or pull requests

2 participants