-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Enhancement] Enforce SSL connection from the client when SSL is enabled on the server #56176
base: main
Are you sure you want to change the base?
Conversation
* Allow only encrypted connections from clients | ||
**/ | ||
@ConfField | ||
public static boolean require_secure_transport = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar config as in MySql server
@@ -106,6 +106,7 @@ public enum ErrorCode { | |||
ERR_NO_SUCH_QUERY(1365, new byte[] {'4', '2', '0', '0', '0'}, "Unknown query id: %s"), | |||
|
|||
ERR_CANNOT_USER(1396, new byte[] {'H', 'Y', '0', '0', '0'}, "Operation %s failed for %s"), | |||
ERR_SECURE_TRANSPORT_REQUIRED(1403, new byte[] {'0', '8', '0', '0', '4'}, "Server rejected the insecure connection"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did we choose the error code 1403?
From the comment in this class, it seems that we should find the corresponding error code for MySQL server/protocol.
// Try our best to compatible with MySQL's
With that, should this be the error code?
Error number: 3159; Symbol: [ER_SECURE_TRANSPORT_REQUIRED](https://dev.mysql.com/doc/mysql-errors/5.7/en/server-error-reference.html#error_er_secure_transport_required); SQLSTATE: HY000
Message: Connections using insecure transport are prohibited while --require_secure_transport=ON.
With the [require_secure_transport](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_require_secure_transport) system variable, clients can connect only using secure transports. Qualifying connections are those using SSL, a Unix socket file, or shared memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @stevenzwu, for checking. I’ll revisit the error code.
@@ -20,6 +20,7 @@ public enum NegotiateState { | |||
READ_AUTH_SWITCH_PKG_FAILED("read auth switch package failed"), | |||
ENABLE_SSL_FAILED("enable ssl failed"), | |||
READ_SSL_AUTH_PKG_FAILED("read ssl auth package failed"), | |||
SERVER_REJECTED_INSECURE_CONNECTION("server rejected the insecure connection"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe remove server
for consistency with other state enum msg, as the state is used by server
. so it is implicitly assumed
INSECURE_CONNECTION_REJECTED(" insecure connection rejected"),
@@ -139,6 +139,13 @@ public static NegotiateResult negotiate(ConnectContext context) throws IOExcepti | |||
return new NegotiateResult(null, NegotiateState.READ_FIRST_AUTH_PKG_FAILED); | |||
} | |||
|
|||
if (Config.require_secure_transport && !authPacket.isSSLConnRequest()) { | |||
LOG.debug("server refused insecure client connection"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be warn
62d1017
to
5a5a3c1
Compare
@@ -139,6 +139,13 @@ public static NegotiateResult negotiate(ConnectContext context) throws IOExcepti | |||
return new NegotiateResult(null, NegotiateState.READ_FIRST_AUTH_PKG_FAILED); | |||
} | |||
|
|||
if (Config.require_secure_transport && !authPacket.isSSLConnRequest()) { | |||
LOG.warn("Copy string literal text to the clipboard"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error msg should be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left one nit comment for log msg. otherwise, LGTM
5a5a3c1
to
23c2d98
Compare
|
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]❌ fail : 4 / 8 (50.00%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
Why I'm doing:
Even when SSL is enabled on server, JDBC clients can still connect without SSL by default, as the server allows connections with or without SSL.
What I'm doing:
Introducing a new boolean config flag to enforce secure connections from clients. When flag is set to true, If clients are connecting without SSL, server refuses client connections
Fixes #56175
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: