Reputation: 107
Is it possible to check if a MySQL server has SSL connections enabled without logging in, assuming we have port and IP?
Upvotes: 1
Views: 224
Reputation: 34232
Theoretically it is possible to do that, but it requires understanding of MySQL's own protocol and advanced socket programming.
As part of the initial handshake process, the mysql server sends an initial handshake packet. As part of capability flags the MySQL server sets the CLIENT_SSL flag if it supports SSL:
The SSL support is announced in Initial Handshake Packet sent by the server via CLIENT_SSL and is enabled if the client returns the same capability.
This packet is sent before the authentication, so you do not have to authenticate to determine if MySQL server support SSL. However, in the various MySQL APIs you cannot simply ask for the initial handshake packet to be sent. Even in the C API you only have mysql_real_connect() that will connect you to the server immediately. So, you need to write your own code to initiate the connection to mysql server, process the server's initial handshake packet, determine if it supports SSL and close the connection.
Upvotes: 2