Browse Source

Exit when ssl_options are provided but the server does not support SSL

Jan Uhlig 3 years ago
parent
commit
abf263942f
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/mysql_protocol.erl

+ 4 - 0
src/mysql_protocol.erl

@@ -393,6 +393,10 @@ server_version_to_list(ServerVersion) ->
 maybe_do_ssl_upgrade(_Host, SockModule0, Socket0, SeqNum1, _Handshake,
                      undefined, _Database, _SetFoundRows) ->
     {ok, SockModule0, Socket0, SeqNum1};
+maybe_do_ssl_upgrade(_Host, _SockModule0, _Socket0, _SeqNum1,
+                     #handshake{capabilities=Caps},_SSLOpts, _Database,
+                     _SetFoundRows) when Caps band ?CLIENT_SSL =/= ?CLIENT_SSL ->
+    exit({failed_to_upgrade_socket, ssl_not_supported});
 maybe_do_ssl_upgrade(Host, gen_tcp, Socket0, SeqNum1, Handshake, SSLOpts,
                      Database, SetFoundRows) ->
     Response = build_handshake_response(Handshake, Database, SetFoundRows),