mirror of
https://github.com/Telecominfraproject/wlan-cloud-rrm.git
synced 2025-11-02 03:28:04 +00:00
Move SSL validation toggle into RRMConfig (#34)
Signed-off-by: Jeffrey Han <39203126+elludraon@users.noreply.github.com>
This commit is contained in:
@@ -158,6 +158,7 @@ public class Launcher implements Callable<Integer> {
|
||||
UCentralUtils.generateServiceKey(config.serviceConfig);
|
||||
|
||||
// Instantiate clients
|
||||
UCentralClient.verifySsl(config.uCentralConfig.verifySsl);
|
||||
UCentralClient client = new UCentralClient(
|
||||
config.serviceConfig.publicEndpoint,
|
||||
config.uCentralConfig.usePublicEndpoints,
|
||||
|
||||
@@ -93,7 +93,13 @@ public class RRMConfig {
|
||||
public String password = "";
|
||||
|
||||
/**
|
||||
* uCentral socket parameters
|
||||
* Verify SSL/TLS certificates in HTTPS requests
|
||||
* ({@code UCENTRALCONFIG_VERIFYSSL})
|
||||
*/
|
||||
public boolean verifySsl = false;
|
||||
|
||||
/**
|
||||
* uCentral socket parameters.
|
||||
*/
|
||||
public class UCentralSocketParams {
|
||||
/**
|
||||
@@ -440,6 +446,9 @@ public class RRMConfig {
|
||||
if ((v = env.get("UCENTRALCONFIG_PASSWORD")) != null) {
|
||||
uCentralConfig.password = v;
|
||||
}
|
||||
if ((v = env.get("UCENTRALCONFIG_VERIFYSSL")) != null) {
|
||||
uCentralConfig.verifySsl = Boolean.parseBoolean(v);
|
||||
}
|
||||
UCentralConfig.UCentralSocketParams uCentralSocketParams =
|
||||
config.uCentralConfig.uCentralSocketParams;
|
||||
if ((v = env.get("UCENTRALSOCKETPARAMS_CONNECTTIMEOUTMS")) != null) {
|
||||
|
||||
@@ -81,9 +81,6 @@ public class UCentralClient {
|
||||
|
||||
static {
|
||||
Unirest.config()
|
||||
// TODO currently disabling SSL/TLS cert verification
|
||||
.verifySsl(false)
|
||||
|
||||
// Suppress unchecked exceptions (ex. SocketTimeoutException),
|
||||
// instead sending a (fake) FailedResponse.
|
||||
.interceptor(new Interceptor() {
|
||||
@@ -105,6 +102,14 @@ public class UCentralClient {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle verifying SSL/TLS certificates. This should be set only during
|
||||
* initialization, otherwise it may NOT take effect.
|
||||
*/
|
||||
public static void verifySsl(boolean enable) {
|
||||
Unirest.config().verifySsl(enable);
|
||||
}
|
||||
|
||||
/** Gson instance */
|
||||
private final Gson gson = new Gson();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user