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

GUACAMOLE-1979: Allow setting required properties for connecting to MySQL 8.4 and later. #1007

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public MySQLAuthenticationProviderModule(MySQLEnvironment environment)
myBatisProperties.setProperty("mybatis.pooled.pingEnabled", "true");
myBatisProperties.setProperty("mybatis.pooled.pingQuery", "SELECT 1");

// Set whether public key retrieval from the server is allowed
driverProperties.setProperty("allowPublicKeyRetrieval",
environment.getMYSQLAllowPublicKeyRetrieval() ? "true" : "false");

// Use UTF-8 in database
driverProperties.setProperty("characterEncoding", "UTF-8");

Expand Down Expand Up @@ -113,10 +117,22 @@ public MySQLAuthenticationProviderModule(MySQLEnvironment environment)
if (clientPassword != null)
driverProperties.setProperty("clientCertificateKeyStorePassword",
clientPassword);

// Get the MySQL-compatible driver to use.
mysqlDriver = environment.getMySQLDriver();

// Set the path to the server public key, if any
// Note that the property name casing is slightly different for MySQL
// and MariaDB drivers. See
// https://dev.mysql.com/doc/connector-j/en/connector-j-connp-props-security.html#cj-conn-prop_serverRSAPublicKeyFile
// and https://mariadb.com/kb/en/about-mariadb-connector-j/#infrequently-used-parameters
String publicKeyFile = environment.getMYSQLServerRSAPublicKeyFile();
if (publicKeyFile != null)
driverProperties.setProperty(
mysqlDriver == MySQLDriver.MYSQL
? "serverRSAPublicKeyFile" : "serverRsaPublicKeyFile",
publicKeyFile);

// If timezone is present, set it.
TimeZone serverTz = environment.getServerTimeZone();
if (serverTz != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,35 @@ public boolean enforceAccessWindowsForActiveSessions() throws GuacamoleException
true);
}

/**
* Returns the absolute path to the public key for the server being connected to,
* if any, or null if the configuration property is unset.
*
* @return
* The absolute path to the public key for the server being connected to.
*
* @throws GuacamoleException
* If an error occurs retrieving the configuration value.
*/
public String getMYSQLServerRSAPublicKeyFile() throws GuacamoleException {
return getProperty(MySQLGuacamoleProperties.MYSQL_SERVER_RSA_PUBLIC_KEY_FILE);
}

/**
* Returns true if the database server public key should be automatically
* retrieved from the MySQL server, or false otherwise.
*
* @return
* Whether the database server public key should be automatically
* retrieved from the MySQL server.
*
* @throws GuacamoleException
* If an error occurs retrieving the configuration value.
*/
public boolean getMYSQLAllowPublicKeyRetrieval() throws GuacamoleException {
return getProperty(
MySQLGuacamoleProperties.MYSQL_ALLOW_PUBLIC_KEY_RETRIEVAL,
false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,29 @@ private MySQLGuacamoleProperties() {}
@Override
public String getName() { return "mysql-batch-size"; }

};

};

/**
* The absolute path to the public key for the server being connected to, if any.
*/
public static final StringGuacamoleProperty MYSQL_SERVER_RSA_PUBLIC_KEY_FILE =
new StringGuacamoleProperty() {

@Override
public String getName() { return "mysql-server-rsa-public-key-file"; }

};

/**
* Whether or not the server public key should be automatically retreived from
* the MySQL server.
*/
public static final BooleanGuacamoleProperty MYSQL_ALLOW_PUBLIC_KEY_RETRIEVAL =
new BooleanGuacamoleProperty() {

@Override
public String getName() { return "mysql-allow-public-key-retrieval"; }

};

}
Loading