GUACAMOLE-926: Add configuration option for enabling self-signed SQL Server certs for local testing.

This commit is contained in:
James Muehlner
2023-05-10 23:26:05 +00:00
parent 353bccb4bc
commit e91d5a99ee
3 changed files with 34 additions and 0 deletions

View File

@@ -77,6 +77,10 @@ public class SQLServerAuthenticationProviderModule implements Module {
// Use UTF-8 in database
driverProperties.setProperty("characterEncoding", "UTF-8");
// Trust unknown server certificates if configured to do so
if (environment.trustAllServerCertificates())
driverProperties.setProperty("trustServerCertificate", "true");
// Retrieve instance name and set it
String instance = environment.getSQLServerInstance();
if (instance != null)

View File

@@ -295,4 +295,21 @@ public class SQLServerEnvironment extends JDBCEnvironment {
true);
}
/**
* Returns true if all server certificates should be trusted, including
* those signed by an unknown certificate authority, such as self-signed
* certificates, or false otherwise.
*
* @throws GuacamoleException
* If an error occurs while retrieving the property value, or if the
* value was not set, as this property is required.
*/
public boolean trustAllServerCertificates() throws GuacamoleException {
// Do not trust unknown certificates unless explicitly enabled
return getProperty(
SQLServerGuacamoleProperties.SQLSERVER_TRUST_ALL_SERVER_CERTIFICATES,
false);
}
}

View File

@@ -245,4 +245,17 @@ public class SQLServerGuacamoleProperties {
};
/**
* Whether or not all server certificates should be trusted, including those
* signed by an unknown certificate authority, such as self-signed
* certificates.
*/
public static final BooleanGuacamoleProperty SQLSERVER_TRUST_ALL_SERVER_CERTIFICATES =
new BooleanGuacamoleProperty() {
@Override
public String getName() { return "sqlserver-trust-all-server-certificates"; }
};
}